Skip to content

Commit

Permalink
Handle non atomic write method when writing on network fs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome.lorrain committed Dec 16, 2020
1 parent 9e5b7d6 commit d22f97f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/rez/serialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/rez/utils/_version.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit d22f97f

Please sign in to comment.