Skip to content

Commit

Permalink
introduced 1 minute timeout for archive's files list building
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed Jun 28, 2020
1 parent 6c5139d commit b1a95cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classesLib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,12 @@ function TtarStream.read(var Buffer; Count: Longint): Longint;

var
i, posBak: int64;
n: integer;
begin
posBak:=pos;
p:=@buffer;
while (count > 0) and (cur < length(flist)) do
n:=length(flist);
while (count > 0) and (cur < n) do
case where of
TW_HEADER:
begin
Expand Down
4 changes: 4 additions & 0 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ TfileListing = class
actualCount: integer;
public
dir: array of Tfile;
timeout: TDateTime;
ignoreConnFilter: boolean;
constructor create();
destructor Destroy; override;
Expand Down Expand Up @@ -1661,6 +1662,8 @@ function TfileListing.fromFolder(folder:Tfile; cd:TconnData;
repeat
application.ProcessMessages();
cd.lastActivityTime:=now();
if cd.lastActivityTime > timeout then
break;
// we don't list these entries
if (sr.name = '.') or (sr.name = '..')
or isCommentFile(sr.name) or isFingerprintFile(sr.name) or sameText(sr.name, DIFF_TPL_FILE)
Expand Down Expand Up @@ -5026,6 +5029,7 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
listing:=TfileListing.create();
try
listing.ignoreConnFilter:=ignoreConnFilters;
listing.timeout:= now()+1/MINUTES;
listing.fromFolder( f, data, shouldRecur(data));
fIsTemp:=f.isTemp();
ofs:=length(f.resource)-length(f.name)+1;
Expand Down

0 comments on commit b1a95cd

Please sign in to comment.