FIX: always clean up uploads with no sha1

This commit is contained in:
Régis Hanol 2017-11-14 10:56:10 +01:00
parent ddff25d7ff
commit ba2209f7d7
1 changed files with 5 additions and 3 deletions

View File

@ -50,9 +50,11 @@ module Jobs
result = result.where("uploads.url NOT IN (?)", ignore_urls) if ignore_urls.present?
result.find_each do |upload|
encoded_sha = Base62.encode(upload.sha1.hex)
next if QueuedPost.where("raw LIKE '%#{upload.sha1}%' OR raw LIKE '%#{encoded_sha}%'").exists?
next if Draft.where("data LIKE '%#{upload.sha1}%' OR data LIKE '%#{encoded_sha}%'").exists?
if upload.sha1.present?
encoded_sha = Base62.encode(upload.sha1.hex)
next if QueuedPost.where("raw LIKE '%#{upload.sha1}%' OR raw LIKE '%#{encoded_sha}%'").exists?
next if Draft.where("data LIKE '%#{upload.sha1}%' OR data LIKE '%#{encoded_sha}%'").exists?
end
upload.destroy
end
end