mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 01:47:24 +08:00
DEV: improve missing uploads query and skip checking file size
This commit is contained in:
parent
593cd831e1
commit
bcdf5b2f47
@ -128,7 +128,7 @@ module FileStore
|
|||||||
verified_ids = []
|
verified_ids = []
|
||||||
|
|
||||||
files.each do |f|
|
files.each do |f|
|
||||||
id = model.where("url LIKE '%#{f.key}' AND filesize = #{f.size}").pluck(:id).first
|
id = model.where("url LIKE '%#{f.key}'").pluck(:id).first if f.size > 0
|
||||||
verified_ids << id if id.present?
|
verified_ids << id if id.present?
|
||||||
marker = f.key
|
marker = f.key
|
||||||
end
|
end
|
||||||
@ -138,7 +138,7 @@ module FileStore
|
|||||||
files = @s3_helper.list(prefix, marker)
|
files = @s3_helper.list(prefix, marker)
|
||||||
end
|
end
|
||||||
|
|
||||||
missing_uploads = model.joins('LEFT JOIN verified_ids ON val = id').where(val: nil)
|
missing_uploads = model.where("id NOT IN (SELECT val FROM verified_ids)")
|
||||||
missing_count = missing_uploads.count
|
missing_count = missing_uploads.count
|
||||||
|
|
||||||
if missing_count > 0
|
if missing_count > 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user