mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
Fix umask usage bit fiddling and use try finally blocks
This commit is contained in:
parent
f2a7978b29
commit
ae59b17e86
@ -485,10 +485,12 @@ class WriteFileMixin(object):
|
||||
# ensure parent directory exists
|
||||
head, tail = os.path.split(abspath_u)
|
||||
|
||||
old_mask = os.umask(self._umask)
|
||||
fileutil.make_dirs(head, ~ self._umask)
|
||||
fileutil.write(replacement_path_u, file_contents)
|
||||
os.umask(old_mask)
|
||||
try:
|
||||
old_mask = os.umask(self._umask)
|
||||
fileutil.make_dirs(head, (~ self._umask) & 0777)
|
||||
fileutil.write(replacement_path_u, file_contents)
|
||||
finally:
|
||||
os.umask(old_mask)
|
||||
|
||||
os.utime(replacement_path_u, (now, now - self.FUDGE_SECONDS))
|
||||
if is_conflict:
|
||||
|
Loading…
Reference in New Issue
Block a user