Ensure file is closed before renaming to improve compatibility with GCS buckets and network filesystems (#3299)

Some filesystems (e.g. GCS FUSE, Samba, NFS) may fail or behave unpredictably when attempting to rename an open file. This update explicitly closes the file before calling rename(), ensuring cross-platform and cloud storage compatibility. The original scope(exit) remains as a fallback to guarantee cleanup.
This commit is contained in:
abraunegg 2025-05-27 05:23:59 +10:00 committed by GitHub
commit 9113feac81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -465,6 +465,11 @@ class CurlEngine {
http.perform();
// close open file - avoids problems with renaming on GCS Buckets and other semi-POSIX systems
if (file.isOpen()){
file.close();
}
// Rename downloaded file
rename(downloadFilename, originalFilename);