FIX: Check if file exists upfront.

This commit is contained in:
Guo Xiang Tan 2016-05-23 10:25:25 +08:00
parent 64e59564dd
commit 26084397c1
No known key found for this signature in database
GPG key ID: 19C321C8952B0F72

View file

@ -12,11 +12,10 @@ module FileStore
def remove_file(url)
return unless is_relative?(url)
path = public_dir + url
return if !File.exists?(path)
tombstone = public_dir + url.sub("/uploads/", "/tombstone/")
FileUtils.mkdir_p(Pathname.new(tombstone).dirname)
FileUtils.move(path, tombstone, :force => true)
rescue Errno::ENOENT
# don't care if the file isn't there
end
def has_been_uploaded?(url)