Not all filesystems on linux supports the RENAME_NOREPLACE flag.
If we get a EINVAL return value, retry with a non atomic operation.
RENAME_NOREPLACE was introduced in 050d48edfc, so this is a regression
fix as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/118571
This commit is contained in:
@@ -480,7 +480,18 @@ int BLI_rename(const char *from, const char *to)
|
||||
#elif defined(__GLIBC_PREREQ)
|
||||
# if __GLIBC_PREREQ(2, 28)
|
||||
/* Most common Linux cases. */
|
||||
return renameat2(AT_FDCWD, from, AT_FDCWD, to, RENAME_NOREPLACE);
|
||||
int ret = renameat2(AT_FDCWD, from, AT_FDCWD, to, RENAME_NOREPLACE);
|
||||
if (ret < 0 && errno == EINVAL) {
|
||||
/* Most likely a filesystem that doesn't support RENAME_NOREPLACE.
|
||||
* (For example NFS, Samba, exFAT, NTFS, etc)
|
||||
* Retry with a non atomic operation.
|
||||
*/
|
||||
if (BLI_exists(to)) {
|
||||
return 1;
|
||||
}
|
||||
return rename(from, to);
|
||||
}
|
||||
return ret;
|
||||
# endif
|
||||
#else
|
||||
/* At least all BSD's currently. */
|
||||
|
||||
Reference in New Issue
Block a user