Skip to content

Commit

Permalink
stale_cachefile: handle if the expected cache file is missing (Juli…
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored and lazarusA committed Aug 17, 2024
1 parent 7c4b40c commit f8b13a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3666,7 +3666,13 @@ end
ignore_loaded::Bool=false, requested_flags::CacheFlags=CacheFlags(),
reasons::Union{Dict{String,Int},Nothing}=nothing, stalecheck::Bool=true)
# n.b.: this function does nearly all of the file validation, not just those checks related to stale, so the name is potentially unclear
io = open(cachefile, "r")
io = try
open(cachefile, "r")
catch ex
ex isa IOError || ex isa SystemError || rethrow()
@debug "Rejecting cache file $cachefile for $modkey because it could not be opened" isfile(cachefile)
return true
end
try
checksum = isvalid_cache_header(io)
if iszero(checksum)
Expand Down
4 changes: 4 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ precompile_test_harness(false) do dir
@test Base.invokelatest(Baz.baz) === 1
@test Baz === UseBaz.Baz

# should not throw if the cachefile does not exist
@test !isfile("DoesNotExist.ji")
@test Base.stale_cachefile("", "DoesNotExist.ji") === true

# Issue #12720
FooBar1_file = joinpath(dir, "FooBar1.jl")
write(FooBar1_file,
Expand Down

0 comments on commit f8b13a7

Please sign in to comment.