mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 02:33:42 +08:00
Rescue errors when running dry run for UploadRecovery
.
This commit is contained in:
parent
d257b4a386
commit
50f7e2be64
|
@ -5,23 +5,28 @@ class UploadRecovery
|
||||||
|
|
||||||
def recover
|
def recover
|
||||||
Post.where("raw LIKE '%upload:\/\/%'").find_each do |post|
|
Post.where("raw LIKE '%upload:\/\/%'").find_each do |post|
|
||||||
analyzer = PostAnalyzer.new(post.raw, post.topic_id)
|
begin
|
||||||
cooked_stripped = analyzer.send(:cooked_stripped)
|
analyzer = PostAnalyzer.new(post.raw, post.topic_id)
|
||||||
|
cooked_stripped = analyzer.send(:cooked_stripped)
|
||||||
|
|
||||||
cooked_stripped.css("img").each do |img|
|
cooked_stripped.css("img").each do |img|
|
||||||
if dom_class = img["class"]
|
if dom_class = img["class"]
|
||||||
if (Post.white_listed_image_classes & dom_class.split).count > 0
|
if (Post.white_listed_image_classes & dom_class.split).count > 0
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if img["data-orig-src"]
|
if img["data-orig-src"]
|
||||||
if @dry_run
|
if @dry_run
|
||||||
puts "#{post.full_url} #{img["data-orig-src"]}"
|
puts "#{post.full_url} #{img["data-orig-src"]}"
|
||||||
else
|
else
|
||||||
recover_post_upload(post, img["data-orig-src"])
|
recover_post_upload(post, img["data-orig-src"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue => e
|
||||||
|
raise e unless @dry_run
|
||||||
|
puts "#{post.full_url} #{e.class}: #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user