v0.36.5 Rewrite broken upload_attachment due to 3.2.5 handling things differently
This commit is contained in:
parent
89e8ebf0b9
commit
cd4e051367
@ -1,7 +1,7 @@
|
|||||||
# Federated Computer, Inc.
|
# Federated Computer, Inc.
|
||||||
# David Sainty <saint@federated.computer> 2024 A.D.
|
# David Sainty <saint@federated.computer> 2024 A.D.
|
||||||
# Gossamer Threads to Discourse -- Migration-Import Script
|
# 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 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -381,8 +381,11 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# Generate SHA1 hash for the file
|
# Generate SHA1 hash for the file
|
||||||
sha1 = Digest::SHA1.file(file.path).hexdigest
|
sha1 = Digest::SHA1.file(file.path).hexdigest
|
||||||
|
|
||||||
# # Ensure the file size is correctly handled
|
# Ensure the file size is correctly handled
|
||||||
# file_size = File.size(file.path)
|
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
|
# Create the upload record, adjusting fields as needed for 3.2.5 compatibility
|
||||||
# upload = Upload.create!(
|
# upload = Upload.create!(
|
||||||
@ -760,11 +763,11 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
puts "#D"
|
puts "#D"
|
||||||
|
|
||||||
# Upload the original image for profile header and user card background
|
# 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?
|
next if upload.nil?
|
||||||
|
|
||||||
# Upload the resized image for the avatar
|
# 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?
|
next if resized_upload.nil?
|
||||||
|
|
||||||
# Ensure the upload ID is valid and exists
|
# Ensure the upload ID is valid and exists
|
||||||
|
Loading…
Reference in New Issue
Block a user