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

do not delete tmp file if storage is local because it has yet to be copied

Markus Kahlf9c32e4a057e
diff --git a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
index 94cab76ac48..06dcecc8af2 100644
--- a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
+++ b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
@@ -77,10 +77,19 @@ module Bim
rescue ArgumentError
errors.add :base, :invalid_ifc_file
ensure
- FileUtils.rm file_path if File.exists? file_path
+ clean_up file_path
end
end
+ def clean_up(file_path)
+ # If we are using direct uploads we can safely discard the file here straight away
+ # after we checked its contents. The actual file has already been uploaded to its final (remote) destination.
+ # For local uploads the file must remain to be copied later to its final (local) destination from the cache.
+ return unless OpenProject::Configuration.direct_uploads?
+
+ FileUtils.rm file_path if File.exists? file_path
+ end
+
def uploader_is_ifc_attachment_author
errors.add :uploader_id, :invalid if model.ifc_attachment && model.uploader != model.ifc_attachment.author
end