mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 10:03:56 +01:00
fix: avoid dupe files in archive in case of ?search=*
This commit is contained in:
parent
61f1a14be6
commit
6e4dcf5b56
@ -99,6 +99,7 @@ type
|
||||
constructor create;
|
||||
destructor Destroy; override;
|
||||
function addFile(src:string; dst:string=''; data:Tobject=NIL):boolean; virtual;
|
||||
function contains(src:string):boolean;
|
||||
function count():integer;
|
||||
procedure reset(); virtual;
|
||||
property totalSize:int64 read getTotal;
|
||||
@ -524,6 +525,16 @@ if cachedTotal < 0 then calculate();
|
||||
result:=cachedTotal;
|
||||
end; // getTotal
|
||||
|
||||
function TarchiveStream.contains(src:string):boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i:=0 to Length(flist)-1 do
|
||||
if flist[i].src = src then
|
||||
exit(TRUE);
|
||||
result:=FALSE;
|
||||
end;
|
||||
|
||||
function TarchiveStream.addFile(src:string; dst:string=''; data:Tobject=NIL):boolean;
|
||||
|
||||
function getMtime(fh:Thandle):int64;
|
||||
|
||||
12
main.pas
12
main.pas
@ -5024,6 +5024,14 @@ var
|
||||
tar: TtarStream;
|
||||
nofolders, selection, itsAsearch: boolean;
|
||||
|
||||
procedure addToTar(src,dst:string);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
if not selection or not tar.contains(src) then
|
||||
tar.addFile(src, dst);
|
||||
end;
|
||||
|
||||
procedure addFolder(f:Tfile; ignoreConnFilters:boolean=FALSE);
|
||||
var
|
||||
i, ofs: integer;
|
||||
@ -5058,7 +5066,7 @@ var
|
||||
else
|
||||
s:=fi.pathTill(f.parent); // we want the path to include also f, so stop at f.parent
|
||||
|
||||
tar.addFile(fi.resource, s);
|
||||
addToTar(fi.resource, s);
|
||||
end
|
||||
finally listing.free end;
|
||||
end; // addFolder
|
||||
@ -5093,7 +5101,7 @@ var
|
||||
t:=substr(s, lastDelimiter('\/', s)+1)
|
||||
else
|
||||
t:=s;
|
||||
tar.addFile(ft.resource, t);
|
||||
addToTar(ft.resource, t);
|
||||
finally freeIfTemp(ft) end;
|
||||
end;
|
||||
end; // addSelection
|
||||
|
||||
Loading…
Reference in New Issue
Block a user