about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-12-08 15:37:12 +0100
committermultiple creatures <dev@multiple-creature.party>2020-02-21 02:24:06 -0600
commit90f2752375145432747c559e0d44e0c86b2eef53 (patch)
treef1071b24156b9d3613047ca99b2f0e463a9e84a2 /app
parent8caf9e4ede78b434443cc2cd65aeaae4412b288f (diff)
port tootsuite#12568 to monsterfork: Add `tootctl media remove-orphans`
Diffstat (limited to 'app')
-rw-r--r--app/models/media_attachment.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 2c195c523..4f0a09784 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -149,6 +149,18 @@ class MediaAttachment < ApplicationRecord
     domains.any? { |domain| blocks.where(domain: domain).or(blocks.where('domain LIKE ?', "%.#{domain}")).exists? }
   end
 
+  def variant?(other_file_name)
+    return true if file_file_name == other_file_name
+
+    formats = file.styles.values.map(&:format).compact
+
+    return false if formats.empty?
+
+    extension = File.extname(other_file_name)
+
+    formats.include?(extension.delete('.')) && File.basename(other_file_name, extension) == File.basename(file_file_name, File.extname(file_file_name))
+  end
+
   def to_param
     shortcode
   end