From 9dd03f922668a15d571b04fd740039942ce8d916 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 12 Aug 2026 22:07:50 +0200 Subject: [PATCH] Download: pass 'target' on to curlInterface as 'targetFile' Since curlInterface can write the body to a file itself, let it: the file then never passes through memory. Older versions ignore the option and still return the contents, which are written here as before. Co-Authored-By: Claude Opus 5 --- lib/download.gi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/download.gi b/lib/download.gi index 4b9a6ce..429f6dc 100644 --- a/lib/download.gi +++ b/lib/download.gi @@ -40,11 +40,18 @@ Add( Download_Methods, rec( if not IsBound( opt.failOnError ) then opt.failOnError:= true; fi; - # 'DownloadURL' handles the options 'verifyCert' and 'maxTime'. + # 'DownloadURL' handles the options 'verifyCert' and 'maxTime'. Newer + # versions can write the body to a file themselves, which keeps it out of + # memory; they call that option 'targetFile'. + if IsBound( opt.target ) and IsString( opt.target ) then + opt.targetFile:= opt.target; + fi; res:= ValueGlobal( "DownloadURL" )( url, opt ); if res.success = true and - IsBound( opt.target ) and IsString( opt.target ) then + IsBound( opt.target ) and IsString( opt.target ) and + IsBound( res.result ) then + # an older 'DownloadURL' ignored 'targetFile' and returned the contents FileString( opt.target, res.result ); Unbind( res.result ); fi;