Fix regression due to 914ada1c749425c4eb53b2d8338afa6b4ab3f3d4.

diff --git a/app/models/concerns/has_url.rb b/app/models/concerns/has_url.rb
index fd0c02f..e7f5f61 100644
--- a/app/models/concerns/has_url.rb
+++ b/app/models/concerns/has_url.rb
@@ -17,8 +17,10 @@ module HasUrl
       return if uri&.path.blank?
       data = extract_url(uri.path)
       return if data.blank?
-
-      self.find_by("url LIKE ?", "%#{data[1]}")
+      sha1 = data[2]
+      result = nil
+      result = self.find_by(sha1: sha1) if sha1&.length == Upload::SHA1_LENGTH
+      result || self.find_by("url LIKE ?", "%#{data[1]}")
     end
   end
 end

GitHub sha: f0bb492d

2 Likes