From 879d2c46527647a8ad87fe65ba07bb069df24767 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 12 Aug 2026 22:07:50 +0200 Subject: [PATCH] Download: tolerate a curlInterface that honours 'target' itself The 'via DownloadURL' method passes the whole option record to 'DownloadURL' and then writes 'res.result' to the target. curlInterface is gaining a 'target' option of its own (gap-packages/curlInterface#62), and then returns no 'result', so this errored with Record Element: '.result' must have an assigned value Guarding on 'result' being bound works with either version, and with the newer one the file is never held in memory as a whole. Co-Authored-By: Claude Opus 5 --- lib/download.gi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/download.gi b/lib/download.gi index 1e01b2e..42a5d57 100644 --- a/lib/download.gi +++ b/lib/download.gi @@ -44,7 +44,11 @@ Add( Download_Methods, rec( 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 + # 'DownloadURL' ignored 'target' and returned the contents, so write + # them out here. A curlInterface that honours 'target' itself returns + # no 'result', and then the file was never held in memory at all. FileString( opt.target, res.result ); Unbind( res.result ); fi;