From d22f97f8674129ab9da43548944d4c35b36807af Mon Sep 17 00:00:00 2001 From: "jerome.lorrain" Date: Wed, 16 Dec 2020 11:00:55 +0100 Subject: [PATCH] Handle non atomic write method when writing on network fs Fix issue #858 --- src/rez/serialise.py | 11 ++++++++--- src/rez/utils/_version.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rez/serialise.py b/src/rez/serialise.py index 75ca5ff08..4a5fcb3d9 100644 --- a/src/rez/serialise.py +++ b/src/rez/serialise.py @@ -73,13 +73,18 @@ def open_file_for_write(filepath, mode=None): with atomic_write(filepath, overwrite=True, **encoding) as f: f.write(content) - except WindowsError as e: - if attempt == 0: + except OSError as e: + # If we are writing to the network, we can't ensure atomicity + if e.errno == 22: + with open(filepath, "w", **encoding) as f: + f.write(content) + + elif attempt == 0: # `overwrite=True` of atomic_write doesn't restore # writability to the file being written to. os.chmod(filepath, stat.S_IWRITE | stat.S_IREAD) - else: + elif sys.platform == "win32": # Under Windows, atomic_write doesn't tell you about # which file actually failed. raise WindowsError("%s: '%s'" % (e, filepath)) diff --git a/src/rez/utils/_version.py b/src/rez/utils/_version.py index e37d8b0a4..990868f90 100644 --- a/src/rez/utils/_version.py +++ b/src/rez/utils/_version.py @@ -1,7 +1,7 @@ # Update this value to version up Rez. Do not place anything else in this file. -_rez_version = "2.69.6" +_rez_version = "2.69.7" # Copyright 2013-2016 Allan Johns.