From b1a95cd319fc8b41436560a9b1095381b2a9b234 Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Sun, 28 Jun 2020 13:57:53 +0200 Subject: [PATCH] introduced 1 minute timeout for archive's files list building --- classesLib.pas | 4 +++- main.pas | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/classesLib.pas b/classesLib.pas index 85443f4..bd716d3 100644 --- a/classesLib.pas +++ b/classesLib.pas @@ -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 diff --git a/main.pas b/main.pas index 985415c..9fce902 100644 --- a/main.pas +++ b/main.pas @@ -1368,6 +1368,7 @@ TfileListing = class actualCount: integer; public dir: array of Tfile; + timeout: TDateTime; ignoreConnFilter: boolean; constructor create(); destructor Destroy; override; @@ -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) @@ -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;