From ffe059a7013dfea37f1b9a7c86938865fbb4e921 Mon Sep 17 00:00:00 2001 From: saint Date: Tue, 2 Jul 2024 19:47:07 +1000 Subject: [PATCH] v0.26 Modify upload attachment code to try and make Discourse happy --- gossamer_forums.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 9b13e44..1b59d7e 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,5 +1,5 @@ # gossamer threads migration-import code -# v0.25.8 +# v0.26 require 'mysql2' require 'open-uri' @@ -372,10 +372,13 @@ class GossamerForumsImporter < ImportScripts::Base # retain_hours: nil ) - # Move the file to the correct location - upload_path = Upload.get_path_for_file(upload.sha1) - FileUtils.mkdir_p(File.dirname(upload_path)) - FileUtils.mv(file.path, upload_path) + # Use Discourse's internal method to upload the file + file.rewind + Discourse.store.upload(file, upload.sha1) + +# # Move the file to the correct location +# upload_path = Upload.get_path_for_file(upload.sha1) +# FileUtils.mkdir_p(File.dirname(upload_path)) # FileUtils.mv(file.path, upload.path) upload.save!