v0.21.4 Fix coding oversight for image upload handling

This commit is contained in:
David Sainty 2024-07-01 12:57:53 +10:00
parent aff0c90976
commit 69611ee3b5

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code
# v0.21.3
# v0.21.4
require 'mysql2'
require 'open-uri'
@ -300,10 +300,10 @@ class GossamerForumsImporter < ImportScripts::Base
end
# Helper method to upload an attachment / image to Discourse
def upload_attachment(user, file, filename, gossamer_url)
def upload_attachment(user_id, file, filename, gossamer_url)
begin
upload = Upload.create!(
user_id: user.id,
user_id: user_id,
original_filename: filename,
filesize: file.size,
# filesize: File.size(file.path),
@ -320,7 +320,7 @@ class GossamerForumsImporter < ImportScripts::Base
upload.save!
upload
rescue => e
puts "Failed to upload attachment #{filename} for user #{user.username}: #{e.message}"
puts "Failed to upload attachment #{filename} for user_id #{user_id}: #{e.message}"
nil
end
end