about summary refs log tree commit diff
path: root/lib/paperclip
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-03-26 01:56:41 +0100
committerGitHub <noreply@github.com>2020-03-26 01:56:41 +0100
commit0c8945e5ff9e75dd322ee2b2c4ea9cc1dc728911 (patch)
treefd2489163804272efcfbca55678de25fb274556a /lib/paperclip
parente187537dfdf8ec1d25479d9ad4d7b0114f30ba65 (diff)
Change `tootctl media remove-orphans` to work for all classes (#13316)
Change `tootctl media lookup` to not use an interactive prompt
Diffstat (limited to 'lib/paperclip')
-rw-r--r--lib/paperclip/attachment_extensions.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb
index 3b308af5f..d9ec0159a 100644
--- a/lib/paperclip/attachment_extensions.rb
+++ b/lib/paperclip/attachment_extensions.rb
@@ -24,6 +24,19 @@ module Paperclip
         flush_deletes
       end
     end
+
+    def variant?(other_filename)
+      return true  if original_filename == other_filename
+      return false if original_filename.nil?
+
+      formats = styles.values.map(&:format).compact
+
+      return false if formats.empty?
+
+      other_extension = File.extname(other_filename)
+
+      formats.include?(other_extension.delete('.')) && File.basename(other_filename, other_extension) == File.basename(original_filename, File.extname(original_filename))
+    end
   end
 end