Skip to content

A platform for community discussion. Free, open, simple.

FIX: errors when copying post_uploads in discourse_merger.rb

Neil Lalondef146f94ef65a
diff --git a/script/bulk_import/discourse_merger.rb b/script/bulk_import/discourse_merger.rb
index 0cf9713950c..ae40b36a8ac 100644
--- a/script/bulk_import/discourse_merger.rb
+++ b/script/bulk_import/discourse_merger.rb
@@ -601,13 +601,11 @@ class BulkImport::DiscourseMerger < BulkImport::Base
def process_post_upload(post_upload)
return nil unless post_upload['upload_id'].present?
- # can't figure out why there are duplicates of these during merge.
- # here's a hack to prevent it:
@imported_post_uploads ||= {}
- return nil if @imported_post_uploads[post_upload['post_id']] == post_upload['upload_id']
- @imported_post_uploads[post_upload['post_id']] = post_upload['upload_id']
+ return nil if @imported_post_uploads[post_upload['post_id']]&.include?(post_upload['upload_id'])
+ @imported_post_uploads[post_upload['post_id']] ||= []
+ @imported_post_uploads[post_upload['post_id']] << post_upload['upload_id']
- # ...and there are still duplicates. So try this:
return nil if PostUpload.where(post_id: post_upload['post_id'], upload_id: post_upload['upload_id']).exists?
post_upload