From cd4e051367e059753139a822e2ef3ab63533e85b Mon Sep 17 00:00:00 2001 From: saint Date: Thu, 15 Aug 2024 00:32:36 +1000 Subject: [PATCH] v0.36.5 Rewrite broken upload_attachment due to 3.2.5 handling things differently --- gossamer_forums.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 1ae2ebe..e51d14d 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,7 +1,7 @@ # Federated Computer, Inc. # David Sainty 2024 A.D. # Gossamer Threads to Discourse -- Migration-Import Script -# v0.36.4 Rewrite broken upload_attachment due to 3.2.5 handling things differently +# v0.36.5 Rewrite broken upload_attachment due to 3.2.5 handling things differently require 'mysql2' require 'open-uri' @@ -381,8 +381,11 @@ class GossamerForumsImporter < ImportScripts::Base # Generate SHA1 hash for the file sha1 = Digest::SHA1.file(file.path).hexdigest -# # Ensure the file size is correctly handled -# file_size = File.size(file.path) + # Ensure the file size is correctly handled + file_size = File.size(file.path) + + puts "Attempting to upload attachment. filename #{filename} user_id #{user_id} file.size #{file.size} file_size #{file_size} sha1 #{sha1} gossamer_url #{gossamer_url}" + # Create the upload record, adjusting fields as needed for 3.2.5 compatibility # upload = Upload.create!( @@ -760,11 +763,11 @@ class GossamerForumsImporter < ImportScripts::Base puts "#D" # Upload the original image for profile header and user card background - upload = upload_attachment(user, temp_file, file['File_Name'], file_url) + upload = upload_attachment(user.id, temp_file, file['File_Name'], file_url) next if upload.nil? # Upload the resized image for the avatar - resized_upload = upload_attachment(user, resized_temp_file, file['File_Name'], file_url) + resized_upload = upload_attachment(user.id, resized_temp_file, file['File_Name'], file_url) next if resized_upload.nil? # Ensure the upload ID is valid and exists