mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Failed file upload shouldn't crash phpBB3 importer
This commit is contained in:
parent
166c56ee0d
commit
bed9135f40
3 changed files with 5 additions and 4 deletions
|
@ -22,7 +22,7 @@ module ImportScripts::PhpBB3
|
|||
filename = CGI.unescapeHTML(row[:real_filename])
|
||||
upload = @uploader.create_upload(user_id, path, filename)
|
||||
|
||||
if upload.nil? || !upload.valid?
|
||||
if upload.nil? || !upload.persisted?
|
||||
puts "Failed to upload #{path}"
|
||||
puts upload.errors.inspect if upload
|
||||
else
|
||||
|
|
|
@ -24,14 +24,15 @@ module ImportScripts::PhpBB3
|
|||
filename = "avatar#{File.extname(path)}"
|
||||
upload = @uploader.create_upload(user.id, path, filename)
|
||||
|
||||
if upload.persisted?
|
||||
if upload.present? && upload.persisted?
|
||||
user.import_mode = false
|
||||
user.create_user_avatar
|
||||
user.import_mode = true
|
||||
user.user_avatar.update(custom_upload_id: upload.id)
|
||||
user.update(uploaded_avatar_id: upload.id)
|
||||
else
|
||||
Rails.logger.error("Could not persist avatar for user #{user.username}")
|
||||
puts "Failed to upload avatar for user #{user.username}: #{path}"
|
||||
puts upload.errors.inspect if upload
|
||||
end
|
||||
rescue SystemCallError => err
|
||||
Rails.logger.error("Could not import avatar for user #{user.username}: #{err.message}")
|
||||
|
|
|
@ -65,7 +65,7 @@ module ImportScripts::PhpBB3
|
|||
filename = File.basename(path)
|
||||
upload = @uploader.create_upload(Discourse::SYSTEM_USER_ID, path, filename)
|
||||
|
||||
if upload.nil? || !upload.valid?
|
||||
if upload.nil? || !upload.persisted?
|
||||
puts "Failed to upload #{path}"
|
||||
puts upload.errors.inspect if upload
|
||||
html = nil
|
||||
|
|
Loading…
Reference in a new issue