mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:16:08 +08:00
Add dry run option to UploadRecovery
.
This commit is contained in:
parent
38668818a5
commit
24c55bd613
|
@ -719,11 +719,13 @@ end
|
|||
task "uploads:recover" => :environment do
|
||||
require_dependency "upload_recovery"
|
||||
|
||||
dry_run = ENV["DRY_RUN"].present?
|
||||
|
||||
if ENV["RAILS_DB"]
|
||||
UploadRecovery.new.recover
|
||||
UploadRecovery.new(dry_run: dry_run).recover
|
||||
else
|
||||
RailsMultisite::ConnectionManagement.each_connection do |db|
|
||||
UploadRecovery.new.recover
|
||||
UploadRecovery.new(dry_run: dry_run).recover
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
class UploadRecovery
|
||||
def initialize(dry_run: false)
|
||||
@dry_run = dry_run
|
||||
end
|
||||
|
||||
def recover
|
||||
Post.where("raw LIKE '%upload:\/\/%'").find_each do |post|
|
||||
analyzer = PostAnalyzer.new(post.raw, post.topic_id)
|
||||
|
@ -12,11 +16,15 @@ class UploadRecovery
|
|||
end
|
||||
|
||||
if img["data-orig-src"]
|
||||
if @dry_run
|
||||
puts "#{post.full_url} #{img["data-orig-src"]}"
|
||||
else
|
||||
recover_post_upload(post, img["data-orig-src"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user