rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on May 14, 2009, 12:15:06 PM

Title: Possible bug with add context menu when select files with same name
Post by: Mars on May 14, 2009, 12:15:06 PM
error resolved by modificate the code

Quote
function Tmainfrm.addFilesFromString(files:string; under:Ttreenode=NIL):Tfile;
......
var
  f: Tfile;
  kind, s, fn, fntemp: string;  //mod by mars
  doubles: TStringDynArray;
  res: integer;
.........
// warn upon double filenames
doubles:=NIL;
s:=files;
while s > '' do
   begin
  fn:=chopLine(s);
  if isExtension(fn, '.lnk')
  or directoryExists(fn) and fileExists(fn+'\target.lnk')
  then
    begin
    fntemp:=resolveLnk(fn);
    files:=xtpl(files,[fn,fntemp]);
    fn:=fntemp;
    end;
  if (length(fn) = 3) and (fn[2] = ':') then fn:=fn[1]+fn[2] // unit root folder
   else fn:=ExtractFileName(fn);
  if existsNodeWithName(fn, under) then
    if addString(fn, doubles) > MAX_DUPE then
      break;
  end;

now there is no sharing filename with ''on 'computer' " and the warning make his come back

BUG if you answer yes on the warning, the name is incremented
 
Title: Re: Possible bug with add context menu when select files with same name
Post by: rejetto on May 14, 2009, 04:36:01 PM
how can i reproduce the bug?
Title: Re: Possible bug with add context menu when select files with same name
Post by: Mars on May 14, 2009, 11:24:43 PM
Create some shortcuts of a folder (or a file), add them to the VFS real or virtual, the names of shortcuts are kept: 'shorcut of name' , 'shorcut[2] of name'  ...

if you create a lot of N shorcuts linkeds to one folder then the same folder is added to the VFS with N differents names at the same place.

With the modification, the resolved name of the folder or file is added to the vfs and incremented if necessary, it is easier to dectect clones

There is another modification bound to the one who never allows to add doubloons
Title: Re: Possible bug with add context menu when select files with same name
Post by: rejetto on May 18, 2009, 03:15:59 PM
i'm not sure how HFS should behave in such case.
i mean, a user asks HFS to add 2 items, that are shortcuts to the same folder, but with different name.
maybe we should just add them as we are doing now.
although it doesn't seem very important to me, i guess the best way to do is what the user expects HFS to do.
if you really think the current way is wrong, i will make a poll.