FIX: errors when copying post_uploads in discourse_merger.rb
This commit is contained in:
parent
04077a7df6
commit
f146f94ef6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue