global-functions: $FetchHuge: another workaround for complete file

Turns out the workaround in $WaitForFile (commit
8231c3e833) is not sufficient. It helps
sometimes, but not always. Possibly depends on CPU speed and bandwidth
of internet connection... Who knows!? 🤪

But! Reading the file goes beyond the known file size. That's suspicious
and indicates this exact issue. So add a delay, and keep reading until
sizes are equal.
This commit is contained in:
Christian Hesse 2024-12-30 20:09:46 +01:00
parent 3ada3055ff
commit 191cc1b952

View file

@ -479,9 +479,13 @@
:local FileSize [ /file/get $FileName size ];
:local Return "";
:local VarSize 0;
:while ($VarSize < $FileSize) do={
:while ($VarSize != $FileSize) do={
:set Return ($Return . ([ /file/read offset=$VarSize chunk-size=32768 file=$FileName as-value ]->"data"));
:set FileSize [ /file/get $FileName size ];
:set VarSize [ :len $Return ];
:if ($VarSize > $FileSize) do={
:delay 100ms;
}
}
/file/remove $DirName;
:return $Return;