From b31772e5bba443dd453704ddd61c3d97f525e6f8 Mon Sep 17 00:00:00 2001 From: saint Date: Mon, 1 Jul 2024 16:20:17 +1000 Subject: [PATCH] v0.22.1 Add debug output for attachment processing --- gossamer_forums.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 3ce201c..a5efebc 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,5 +1,5 @@ # gossamer threads migration-import code -# v0.22 +# v0.22.1 require 'mysql2' require 'open-uri' @@ -350,6 +350,7 @@ class GossamerForumsImporter < ImportScripts::Base def handle_post_attachments(gossamer_post_id, post, user_id) execute_query("SELECT * FROM gforum_PostAttachment WHERE post_id_fk = #{gossamer_post_id}").each do |att_row| attachment_url = "https://forum.slowtwitch.com/forum/?do=post_attachment;postatt_id=#{att_row['postatt_id']}" + puts "Handling attachment: #{attachment_url}" attachment_data = download_attachment(attachment_url) next unless attachment_data @@ -358,11 +359,14 @@ class GossamerForumsImporter < ImportScripts::Base temp_file.binmode temp_file.write(attachment_data) temp_file.rewind - + + puts "Attempting upload..." upload = upload_attachment(user_id, temp_file, att_row['postatt_filename'], attachment_url) next unless upload upload_url = upload.url + + puts "Appending to post.raw... #{upload_url} MIME type: #{mime_type}" if mime_type.start_with?('image/') post.raw += "\n![#{att_row['postatt_filename']}](#{upload_url})" else