From 5b934cb33ddf042d64e1461d98486747716540da Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 24 Apr 2019 16:44:32 +0800 Subject: [PATCH] FIX: Error when trying to move the same file to tombstone. If an optimized image is destroyed when a previous similar optimized image is already placed in the tombstone, `FileUtils.move` will blow up. --- lib/file_store/local_store.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/file_store/local_store.rb b/lib/file_store/local_store.rb index 988497c0b20..09af9701f3a 100644 --- a/lib/file_store/local_store.rb +++ b/lib/file_store/local_store.rb @@ -16,6 +16,7 @@ module FileStore destination = "#{public_dir}#{url.sub("/uploads/", "/uploads/tombstone/")}" dir = Pathname.new(destination).dirname FileUtils.mkdir_p(dir) unless Dir.exists?(dir) + FileUtils.remove(destination) if File.exists?(destination) FileUtils.move(source, destination, force: true) FileUtils.touch(destination) end