FIX: only call 'unlink' for tempfiles

FIX: only call ‘unlink’ for tempfiles

diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb
index fbcc562..74a45ad 100644
--- a/app/models/optimized_image.rb
+++ b/app/models/optimized_image.rb
@@ -407,8 +407,8 @@ class OptimizedImage < ActiveRecord::Base
           # just ditch the optimized image if there was any errors
           optimized_image.destroy
         ensure
-          file&.unlink
           file&.close
+          file&.unlink if file&.respond_to?(:unlink)
         end
       end
     end

GitHub sha: ad12b2a2

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: