Skip to content

Commit

Permalink
update the Julia code for downloading files
Browse files Browse the repository at this point in the history
- avoid the call `JuliaImportPackage("Downloads")`,
  which somehow does not work as expected in certain situations,
  see oscar-system/GAP.jl/issues/1040

- update the code of the function such that it contains the changes from
  oscar-system/GAP.jl/pull/961

  (Yes, the new code looks ugly, and the next GAP.jl version will contain
  support for the "call with catch *and* keyword arguments" situation.)
  • Loading branch information
ThomasBreuer committed Sep 18, 2024
1 parent bf160fa commit 105f5ad
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions gap/Julia.g
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
# (Note that Downloads.jl gets loaded by GAP.jl.)
# For that, we replace the code of `PKGMAN_DownloadURL`.

if IsBound(Julia) and JuliaImportPackage("Downloads") = true then
if IsBound(Julia) then
MakeReadWriteGlobal("PKGMAN_DownloadURL");
UnbindGlobal("PKGMAN_DownloadURL");
BindGlobal("PKGMAN_DownloadURL", function(url)
local res;

res := CallJuliaFunctionWithCatch(Julia.Downloads.download,
[Julia.string(url), Julia.IOBuffer()]);
if res.ok then
res := Julia.String(Julia.("take!")(res.value));
res := Julia.GAP.call_with_catch(
Julia.GAP.UnwrapJuliaFunc(Julia.GAP.kwarg_wrapper),
GAPToJulia([Julia.GAP.Packages.Downloads.download,
[Julia.string(url), Julia.IOBuffer()],
rec(downloader:= Julia.getindex(
Julia.GAP.Packages.DOWNLOAD_HELPER))]));
if res[1] = true then
res := Julia.String(Julia.take\!(res[2]));
return rec(success := true, result := JuliaToGAP(IsString, res));
else
return rec(success := false);
Expand Down

0 comments on commit 105f5ad

Please sign in to comment.