Skip to content

Commit 6e4dcf5

Browse files
committed
fix: avoid dupe files in archive in case of ?search=*
1 parent 61f1a14 commit 6e4dcf5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

classesLib.pas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ TarchiveStream = class(Tstream)
9999
constructor create;
100100
destructor Destroy; override;
101101
function addFile(src:string; dst:string=''; data:Tobject=NIL):boolean; virtual;
102+
function contains(src:string):boolean;
102103
function count():integer;
103104
procedure reset(); virtual;
104105
property totalSize:int64 read getTotal;
@@ -524,6 +525,16 @@ function TarchiveStream.getTotal():int64;
524525
result:=cachedTotal;
525526
end; // getTotal
526527

528+
function TarchiveStream.contains(src:string):boolean;
529+
var
530+
i: integer;
531+
begin
532+
for i:=0 to Length(flist)-1 do
533+
if flist[i].src = src then
534+
exit(TRUE);
535+
result:=FALSE;
536+
end;
537+
527538
function TarchiveStream.addFile(src:string; dst:string=''; data:Tobject=NIL):boolean;
528539

529540
function getMtime(fh:Thandle):int64;

main.pas

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5024,6 +5024,14 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
50245024
tar: TtarStream;
50255025
nofolders, selection, itsAsearch: boolean;
50265026

5027+
procedure addToTar(src,dst:string);
5028+
var
5029+
i: integer;
5030+
begin
5031+
if not selection or not tar.contains(src) then
5032+
tar.addFile(src, dst);
5033+
end;
5034+
50275035
procedure addFolder(f:Tfile; ignoreConnFilters:boolean=FALSE);
50285036
var
50295037
i, ofs: integer;
@@ -5058,7 +5066,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
50585066
else
50595067
s:=fi.pathTill(f.parent); // we want the path to include also f, so stop at f.parent
50605068

5061-
tar.addFile(fi.resource, s);
5069+
addToTar(fi.resource, s);
50625070
end
50635071
finally listing.free end;
50645072
end; // addFolder
@@ -5093,7 +5101,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
50935101
t:=substr(s, lastDelimiter('\/', s)+1)
50945102
else
50955103
t:=s;
5096-
tar.addFile(ft.resource, t);
5104+
addToTar(ft.resource, t);
50975105
finally freeIfTemp(ft) end;
50985106
end;
50995107
end; // addSelection

0 commit comments

Comments
 (0)