Fix regression due to 914ada1c74.

This commit is contained in:
Guo Xiang Tan 2019-04-09 09:47:11 +08:00
parent f5ac01253a
commit f0bb492d24
1 changed files with 4 additions and 2 deletions

View File

@ -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