From 8d4d382f8b5b9debb8f6952e5648e3d77c306a01 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Mon, 7 Oct 2024 16:08:40 -0400 Subject: [PATCH] rescue chown in case it fails (#3856) Rescue chown in case it fails so the upload completes as successful. --- apps/dashboard/app/models/posix_file.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/app/models/posix_file.rb b/apps/dashboard/app/models/posix_file.rb index eb9574eff0..9456bbd931 100644 --- a/apps/dashboard/app/models/posix_file.rb +++ b/apps/dashboard/app/models/posix_file.rb @@ -151,7 +151,14 @@ def handle_upload(tempfile) FileUtils.mv tempfile, path.to_s File.chmod(mode, path.to_s) - path.chown(nil, path.parent.stat.gid) if path.parent.setgid? + begin + gid = path.parent.stat.gid + path.chown(nil, gid) if path.parent.setgid? + rescue StandardError => e + Rails.logger.info("Cannot change group ownership of #{path} to #{gid} because of error: #{e}") + end + + nil end def can_download_as_zip?(timeout: Configuration.file_download_dir_timeout, download_directory_size_limit: Configuration.file_download_dir_max)