v0.26 Modify upload attachment code to try and make Discourse happy

This commit is contained in:
David Sainty 2024-07-02 19:47:07 +10:00
parent b8fbaf6e43
commit ffe059a701

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code # gossamer threads migration-import code
# v0.25.8 # v0.26
require 'mysql2' require 'mysql2'
require 'open-uri' require 'open-uri'
@ -372,10 +372,13 @@ class GossamerForumsImporter < ImportScripts::Base
# retain_hours: nil # retain_hours: nil
) )
# Move the file to the correct location # Use Discourse's internal method to upload the file
upload_path = Upload.get_path_for_file(upload.sha1) file.rewind
FileUtils.mkdir_p(File.dirname(upload_path)) Discourse.store.upload(file, upload.sha1)
FileUtils.mv(file.path, upload_path)
# # 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) # FileUtils.mv(file.path, upload.path)
upload.save! upload.save!