Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stale_cachefile: handle if the expected cache file is missing #55419

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3664,7 +3664,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