Fix public_data:commit's symlinking on some platforms

Huh, curious, I think what I'm seeing is: on my development machine,
`File.exist?` returns true for symlinks, but, on our production
machine, `File.exist?` returns false for symlinks.

I imagine this is a difference in the implementation of the underlying
system calls? Curious!

This new check should work more reliably across platforms. I considered
checking both `exists?` and `symlink?`, but decided that, in the
unexpected case that `latest.sql.gz` exists but is an actual file
instead of a symlink like we expect, it's probably best to avoid
overwriting it anyway, and a crash on the `symlink` attempt is a
reasonable way to do that.
This commit is contained in:
Emi Matchu 2024-05-02 13:10:30 -07:00
parent 7c09b76b5e
commit c751173c52
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ namespace :public_data do
# Link this latest dump as `latest.sql.gz`.
latest_path = Rails.configuration.public_data_root / "latest.sql.gz"
File.unlink(latest_path) if File.exist?(latest_path)
File.unlink(latest_path) if File.symlink?(latest_path)
File.symlink(dest_path, latest_path)
puts "Linked dump to #{latest_path}"