@@ -287,71 +287,46 @@ function download_artifact(
287
287
return true
288
288
end
289
289
290
- if Sys. iswindows ()
291
- # The destination directory we're hoping to fill:
292
- dest_dir = artifact_path (tree_hash; honor_overrides= false )
293
- mkpath (dest_dir)
294
-
295
- # On Windows, we have some issues around stat() and chmod() that make properly
296
- # determining the git tree hash problematic; for this reason, we use the "unsafe"
297
- # artifact unpacking method, which does not properly verify unpacked git tree
298
- # hash. This will be fixed in a future Julia release which will properly interrogate
299
- # the filesystem ACLs for executable permissions, which git tree hashes care about.
300
- try
301
- download_verify_unpack (tarball_url, tarball_hash, dest_dir, ignore_existence= true ,
302
- verbose= verbose, quiet_download= quiet_download, io= io)
303
- catch err
304
- @debug " download_artifact error" tree_hash tarball_url tarball_hash err
305
- # Clean that destination directory out if something went wrong
306
- rm (dest_dir; force= true , recursive= true )
307
-
308
- if isa (err, InterruptException)
309
- rethrow (err)
310
- end
311
- return err
290
+ # We download by using `create_artifact()`. We do this because the download may
291
+ # be corrupted or even malicious; we don't want to clobber someone else's artifact
292
+ # by trusting the tree hash that has been given to us; we will instead download it
293
+ # to a temporary directory, calculate the true tree hash, then move it to the proper
294
+ # location only after knowing what it is, and if something goes wrong in the process,
295
+ # everything should be cleaned up. Luckily, that is precisely what our
296
+ # `create_artifact()` wrapper does, so we use that here.
297
+ calc_hash = try
298
+ create_artifact () do dir
299
+ download_verify_unpack (tarball_url, tarball_hash, dir, ignore_existence= true , verbose= verbose,
300
+ quiet_download= quiet_download, io= io)
312
301
end
313
- else
314
- # We download by using `create_artifact()`. We do this because the download may
315
- # be corrupted or even malicious; we don't want to clobber someone else's artifact
316
- # by trusting the tree hash that has been given to us; we will instead download it
317
- # to a temporary directory, calculate the true tree hash, then move it to the proper
318
- # location only after knowing what it is, and if something goes wrong in the process,
319
- # everything should be cleaned up. Luckily, that is precisely what our
320
- # `create_artifact()` wrapper does, so we use that here.
321
- calc_hash = try
322
- create_artifact () do dir
323
- download_verify_unpack (tarball_url, tarball_hash, dir, ignore_existence= true , verbose= verbose,
324
- quiet_download= quiet_download, io= io)
325
- end
326
- catch err
327
- @debug " download_artifact error" tree_hash tarball_url tarball_hash err
328
- if isa (err, InterruptException)
329
- rethrow (err)
330
- end
331
- # If something went wrong during download, return the error
332
- return err
302
+ catch err
303
+ @debug " download_artifact error" tree_hash tarball_url tarball_hash err
304
+ if isa (err, InterruptException)
305
+ rethrow (err)
333
306
end
307
+ # If something went wrong during download, return the error
308
+ return err
309
+ end
334
310
335
- # Did we get what we expected? If not, freak out.
336
- if calc_hash. bytes != tree_hash. bytes
337
- msg = " Tree Hash Mismatch!\n "
338
- msg *= " Expected git-tree-sha1: $(bytes2hex (tree_hash. bytes)) \n "
339
- msg *= " Calculated git-tree-sha1: $(bytes2hex (calc_hash. bytes)) "
340
- # Since tree hash calculation is still broken on some systems, e.g. Pkg.jl#1860,
341
- # and Pkg.jl#2317 so we allow setting JULIA_PKG_IGNORE_HASHES=1 to ignore the
342
- # error and move the artifact to the expected location and return true
343
- ignore_hash = Base. get_bool_env (" JULIA_PKG_IGNORE_HASHES" , false )
344
- if ignore_hash
345
- msg *= " \n\$ JULIA_PKG_IGNORE_HASHES is set to 1: ignoring error and moving artifact to the expected location"
346
- @error (msg)
347
- # Move it to the location we expected
348
- src = artifact_path (calc_hash; honor_overrides= false )
349
- dst = artifact_path (tree_hash; honor_overrides= false )
350
- mv (src, dst; force= true )
351
- return true
352
- end
353
- return ErrorException (msg)
311
+ # Did we get what we expected? If not, freak out.
312
+ if calc_hash. bytes != tree_hash. bytes
313
+ msg = " Tree Hash Mismatch!\n "
314
+ msg *= " Expected git-tree-sha1: $(bytes2hex (tree_hash. bytes)) \n "
315
+ msg *= " Calculated git-tree-sha1: $(bytes2hex (calc_hash. bytes)) "
316
+ # Since tree hash calculation is still broken on some systems, e.g. Pkg.jl#1860,
317
+ # and Pkg.jl#2317, we allow setting JULIA_PKG_IGNORE_HASHES=1 to ignore the
318
+ # error and move the artifact to the expected location and return true
319
+ ignore_hash = Base. get_bool_env (" JULIA_PKG_IGNORE_HASHES" , false )
320
+ if ignore_hash
321
+ msg *= " \n\$ JULIA_PKG_IGNORE_HASHES is set to 1: ignoring error and moving artifact to the expected location"
322
+ @error (msg)
323
+ # Move it to the location we expected
324
+ src = artifact_path (calc_hash; honor_overrides= false )
325
+ dst = artifact_path (tree_hash; honor_overrides= false )
326
+ mv (src, dst; force= true )
327
+ return true
354
328
end
329
+ return ErrorException (msg)
355
330
end
356
331
357
332
return true
0 commit comments