OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
code cleanup
ulferts54dfe2e274d0
diff --git a/app/services/copy/concerns/copy_attachments.rb b/app/services/copy/concerns/copy_attachments.rbindex 621042e0129..93222e61c23 100644--- a/app/services/copy/concerns/copy_attachments.rb+++ b/app/services/copy/concerns/copy_attachments.rb@@ -6,21 +6,28 @@ module Copydef copy_attachments(container_type, from_id:, to_id:)Attachment.where(container_type:, container_id: from_id)- .find_each do |old_attachment|- copied = old_attachment.dup- old_attachment.file.copy_to(copied)+ .find_each do |source|- copied.author = user- copied.container_type = old_attachment.container_type- copied.container_id = to_id+ copy = Attachment+ .new(attachment_copy_attributes(source, to_id))+ source.file.copy_to(copy)- unless copied.save- Rails.logger.error { "Attachments ##{old_attachment.id} could not be copied: #{copied.errors.full_messages} " }+ unless copy.save+ Rails.logger.error { "Attachments ##{source.id} could not be copy: #{copy.errors.full_messages} " }endrescue StandardError => e- Rails.logger.error { "Failed to copy attachments from ##{from_container_id} to ##{to_container_id}: #{e}" }+ Rails.logger.error { "Failed to copy attachments from ##{from_id} to ##{to_id}: #{e}" }endend++ def attachment_copy_attributes(source, to_id)+ source+ .dup+ .attributes+ .except('file')+ .merge('author_id' => user.id,+ 'container_id' => to_id)+ endendendend