Fix startup failure if the cache directory points to a broken symlink
This commit is contained in:
parent
8394834cd5
commit
aef82de32c
|
@ -1,5 +1,7 @@
|
|||
# Unreleased
|
||||
|
||||
* Fix startup failure if the cache directory points to a broken symlink.
|
||||
|
||||
# 1.18.3
|
||||
|
||||
* Fix the cache corruption issue in the revalidation feature. See #474.
|
||||
|
|
|
@ -122,6 +122,8 @@ module Bootsnap
|
|||
stack.reverse_each do |dir|
|
||||
Dir.mkdir(dir)
|
||||
rescue SystemCallError
|
||||
# Check for broken symlinks. Calling File.realpath will raise Errno::ENOENT if that is the case
|
||||
File.realpath(dir) if File.symlink?(dir)
|
||||
raise unless File.directory?(dir)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,6 +85,13 @@ module Bootsnap
|
|||
store.transaction { store.set("a", 1) }
|
||||
end
|
||||
|
||||
def test_with_broken_symlink
|
||||
FileUtils.ln_s(@path, "#{@dir}/store_broken")
|
||||
store = Store.new("#{@dir}/store_broken/store")
|
||||
|
||||
store.transaction { store.set("a", "b") }
|
||||
end
|
||||
|
||||
def test_ignore_read_only_filesystem
|
||||
MessagePack.expects(:dump).raises(Errno::EROFS.new("Read-only file system @ rb_sysopen"))
|
||||
store.transaction { store.set("a", 1) }
|
||||
|
|
Loading…
Reference in New Issue