From: David Stainton Date: Tue, 8 Dec 2015 15:44:59 +0000 (+0200) Subject: Fix umask usage bit fiddling and use try finally blocks X-Git-Url: https://git.rkrishnan.org/pf/content/vdrive?a=commitdiff_plain;h=be2f088bc7913bb4b1c1ecb3ddf112495228c1b2;p=tahoe-lafs%2Ftahoe-lafs.git Fix umask usage bit fiddling and use try finally blocks --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index e1fbff61..c22efaea 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -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: