File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -354,10 +354,22 @@ function download_artifact(
354354 msg = " Tree Hash Mismatch!\n "
355355 msg *= " Expected git-tree-sha1: $(bytes2hex (tree_hash. bytes)) \n "
356356 msg *= " Calculated git-tree-sha1: $(bytes2hex (calc_hash. bytes)) "
357+ # Since tree hash calculation is still broken on some systems, e.g. Pkg.jl#1860,
358+ # and Pkg.jl#2317 so we allow setting JULIA_PKG_IGNORE_HASHES=1 to ignore the
359+ # error and move the artifact to the expected location and return true
360+ ignore_hash = get (ENV , " JULIA_PKG_IGNORE_HASHES" , nothing ) == " 1"
361+ if ignore_hash
362+ msg *= " \n\$ JULIA_PKG_IGNORE_HASHES is set to 1: ignoring error and moving artifact to the expected location"
363+ end
357364 @error (msg)
358- # Tree hash calculation is still broken on some systems, e.g. Pkg.jl#1860,
359- # so we return true here and only raise the warning on the lines above.
360- # return false
365+ if ignore_hash
366+ # Move it to the location we expected
367+ src = artifact_path (calc_hash; honor_overrides= false )
368+ dst = artifact_path (tree_hash; honor_overrides= false )
369+ mv (src, dst; force= true )
370+ return true
371+ end
372+ return false
361373 end
362374 end
363375
Original file line number Diff line number Diff line change @@ -268,17 +268,20 @@ end
268268
269269 # Next, test incorrect download errors
270270 if ! Sys. iswindows ()
271- mktempdir () do dir
271+ for ignore_hash in ( false , true ); withenv ( " JULIA_PKG_IGNORE_HASHES " => ignore_hash ? " 1 " : nothing ) do ; mktempdir () do dir
272272 with_artifacts_directory (dir) do
273273 @test artifact_meta (" broken_artifact" , joinpath (badifact_dir, " incorrect_gitsha.toml" )) != nothing
274274 @test_logs (:error , r" Tree Hash Mismatch!" ) match_mode= :any begin
275- # Only warn on wrong tree hash for now (see Pkg.jl#1885)
276- # @test_throws ErrorException ensure_artifact_installed("broken_artifact", joinpath(badifact_dir, "incorrect_gitsha.toml"))
277- path = ensure_artifact_installed (" broken_artifact" , joinpath (badifact_dir, " incorrect_gitsha.toml" ))
278- @test endswith (path, " 0000000000000000000000000000000000000000" )
275+ if ! ignore_hash
276+ @test_throws ErrorException ensure_artifact_installed (" broken_artifact" , joinpath (badifact_dir, " incorrect_gitsha.toml" ))
277+ else
278+ path = ensure_artifact_installed (" broken_artifact" , joinpath (badifact_dir, " incorrect_gitsha.toml" ))
279+ @test endswith (path, " 0000000000000000000000000000000000000000" )
280+ @test isdir (path)
281+ end
279282 end
280283 end
281- end
284+ end end end
282285 end
283286
284287 mktempdir () do dir
You can’t perform that action at this time.
0 commit comments