A platform for community discussion. Free, open, simple.
FIX: Linting
Robin Ward588f61f717d5
diff --git a/app/jobs/scheduled/ensure_post_uploads_existence.rb b/app/jobs/scheduled/ensure_post_uploads_existence.rbindex 0e2a8bed597..327bdddb4a8 100644--- a/app/jobs/scheduled/ensure_post_uploads_existence.rb+++ b/app/jobs/scheduled/ensure_post_uploads_existence.rb@@ -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+ 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+ 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+ endendendend