mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 03:03:45 +08:00
better error handling for upload extension fixer
This commit is contained in:
parent
0451dba27a
commit
1fc2597626
|
@ -713,5 +713,5 @@ end
|
|||
|
||||
task "uploads:fix_incorrect_extensions" => :environment do
|
||||
require_dependency "upload_fixer"
|
||||
UploadFixer.fix_extensions
|
||||
UploadFixer.fix_all_extensions
|
||||
end
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
class UploadFixer
|
||||
def self.fix_extensions
|
||||
def self.fix_all_extensions
|
||||
Upload.where("uploads.extension IS NOT NULL").find_each do |upload|
|
||||
fix_extension_on_upload(upload)
|
||||
end
|
||||
end
|
||||
|
||||
def self.fix_extension_on_upload(upload)
|
||||
is_external = Discourse.store.external?
|
||||
previous_url = upload.url.dup
|
||||
|
||||
|
@ -65,9 +70,12 @@ class UploadFixer
|
|||
tombstone_path
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts "Skipping upload: ailed to correct extension on upload id: #{upload.id} #{current_extension} => #{correct_extension}"
|
||||
STDERR.puts e
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in New Issue
Block a user