mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
DEV: raise error only when 'STOP_ON_ERROR' env variable is available.
This commit is contained in:
@ -898,12 +898,13 @@ task "uploads:recover" => :environment do
|
|||||||
require_dependency "upload_recovery"
|
require_dependency "upload_recovery"
|
||||||
|
|
||||||
dry_run = ENV["DRY_RUN"].present?
|
dry_run = ENV["DRY_RUN"].present?
|
||||||
|
stop_on_error = ENV["STOP_ON_ERROR"].present?
|
||||||
|
|
||||||
if ENV["RAILS_DB"]
|
if ENV["RAILS_DB"]
|
||||||
UploadRecovery.new(dry_run: dry_run).recover
|
UploadRecovery.new(dry_run: dry_run, stop_on_error: stop_on_error).recover
|
||||||
else
|
else
|
||||||
RailsMultisite::ConnectionManagement.each_connection do |db|
|
RailsMultisite::ConnectionManagement.each_connection do |db|
|
||||||
UploadRecovery.new(dry_run: dry_run).recover
|
UploadRecovery.new(dry_run: dry_run, stop_on_error: stop_on_error).recover
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UploadRecovery
|
class UploadRecovery
|
||||||
def initialize(dry_run: false)
|
def initialize(dry_run: false, stop_on_error: false)
|
||||||
@dry_run = dry_run
|
@dry_run = dry_run
|
||||||
|
@stop_on_error = stop_on_error
|
||||||
end
|
end
|
||||||
|
|
||||||
def recover(posts = Post)
|
def recover(posts = Post)
|
||||||
@ -40,7 +41,7 @@ class UploadRecovery
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
raise e unless @dry_run
|
raise e if @stop_on_error
|
||||||
puts "#{post.full_url} #{e.class}: #{e.message}"
|
puts "#{post.full_url} #{e.class}: #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user