Skip to content

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

consider validation errors during pending attachment creation

Markus Kahlb483e6cd3592
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index ba9cc36cf5d..39caceb3309 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -265,11 +265,13 @@ class Attachment < ApplicationRecord
downloads: -1
)
- # We need to use update_column because `file` is an uploader which expects a File (not a string)
+ # We need to do it like this because `file` is an uploader which expects a File (not a string)
# to upload usually. But in this case the data has already been uploaded and we just point to it.
- a.update_column :file, file_name
+ a[:file] = file_name
- a.reload
+ a.reload unless a.new_record?
+
+ a
end
def pending_direct_upload?