v0.22.1 Add debug output for attachment processing
This commit is contained in:
parent
dd5f3a9333
commit
b31772e5bb
@ -1,5 +1,5 @@
|
|||||||
# gossamer threads migration-import code
|
# gossamer threads migration-import code
|
||||||
# v0.22
|
# v0.22.1
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -350,6 +350,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
def handle_post_attachments(gossamer_post_id, post, user_id)
|
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|
|
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']}"
|
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)
|
attachment_data = download_attachment(attachment_url)
|
||||||
next unless attachment_data
|
next unless attachment_data
|
||||||
|
|
||||||
@ -359,10 +360,13 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
temp_file.write(attachment_data)
|
temp_file.write(attachment_data)
|
||||||
temp_file.rewind
|
temp_file.rewind
|
||||||
|
|
||||||
|
puts "Attempting upload..."
|
||||||
upload = upload_attachment(user_id, temp_file, att_row['postatt_filename'], attachment_url)
|
upload = upload_attachment(user_id, temp_file, att_row['postatt_filename'], attachment_url)
|
||||||
next unless upload
|
next unless upload
|
||||||
|
|
||||||
upload_url = upload.url
|
upload_url = upload.url
|
||||||
|
|
||||||
|
puts "Appending to post.raw... #{upload_url} MIME type: #{mime_type}"
|
||||||
if mime_type.start_with?('image/')
|
if mime_type.start_with?('image/')
|
||||||
post.raw += "\n![#{att_row['postatt_filename']}](#{upload_url})"
|
post.raw += "\n![#{att_row['postatt_filename']}](#{upload_url})"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user