FIX: Linting
This commit is contained in:
parent
a4ff593506
commit
588f61f717
|
@ -18,30 +18,29 @@ module Jobs
|
|||
.where("(posts.cooked LIKE '%<a %' OR posts.cooked LIKE '%<img %') AND cf.id IS NULL")
|
||||
.find_in_batches(batch_size: 100) do |posts|
|
||||
|
||||
Post.preload_custom_fields(posts, [MISSING_UPLOADS])
|
||||
Post.preload_custom_fields(posts, [MISSING_UPLOADS])
|
||||
posts.each do |post|
|
||||
fragments ||= Nokogiri::HTML::fragment(post.cooked)
|
||||
missing = []
|
||||
|
||||
posts.each do |post|
|
||||
fragments ||= Nokogiri::HTML::fragment(post.cooked)
|
||||
missing = []
|
||||
fragments.css("a/@href", "img/@src").each do |media|
|
||||
src = media.value
|
||||
next if src.blank? || (src =~ /\/uploads\//).blank?
|
||||
|
||||
fragments.css("a/@href", "img/@src").each do |media|
|
||||
src = media.value
|
||||
next if src.blank? || (src =~ /\/uploads\//).blank?
|
||||
src = "#{SiteSetting.force_https ? "https" : "http"}:#{src}" if src.start_with?("//")
|
||||
next unless Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i
|
||||
|
||||
src = "#{SiteSetting.force_https ? "https" : "http"}:#{src}" if src.start_with?("//")
|
||||
next unless Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i
|
||||
|
||||
missing << src unless Upload.get_from_url(src) || OptimizedImage.get_from_url(src)
|
||||
end
|
||||
|
||||
if missing.present?
|
||||
post.preloaded_custom_fields = nil
|
||||
post.custom_fields[MISSING_UPLOADS] = missing
|
||||
post.save_custom_fields
|
||||
elsif post.custom_fields[MISSING_UPLOADS].present?
|
||||
PostCustomField.find_by(post_id: post.id, name: MISSING_UPLOADS).destroy!
|
||||
end
|
||||
missing << src unless Upload.get_from_url(src) || OptimizedImage.get_from_url(src)
|
||||
end
|
||||
|
||||
if missing.present?
|
||||
post.preloaded_custom_fields = nil
|
||||
post.custom_fields[MISSING_UPLOADS] = missing
|
||||
post.save_custom_fields
|
||||
elsif post.custom_fields[MISSING_UPLOADS].present?
|
||||
PostCustomField.find_by(post_id: post.id, name: MISSING_UPLOADS).destroy!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue