]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add umask to Downloader
authorDavid Stainton <dstainton415@gmail.com>
Tue, 8 Dec 2015 00:47:27 +0000 (02:47 +0200)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 25 Jan 2016 15:54:28 +0000 (15:54 +0000)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 62e6988d1ef96aab8e4390750a80a8b6a2f8fa83..317500a935a51ede05140dbfed04539b338e7b5c 100644 (file)
@@ -484,10 +484,12 @@ class WriteFileMixin(object):
 
         # ensure parent directory exists
         head, tail = os.path.split(abspath_u)
-        mode = 0777 # XXX
-        fileutil.make_dirs(head, mode)
 
+        old_mask = os.umask(self._umask)
+        fileutil.make_dirs(head, ~ self._umask)
         fileutil.write(replacement_path_u, file_contents)
+        os.umask(old_mask)
+
         os.utime(replacement_path_u, (now, now - self.FUDGE_SECONDS))
         if is_conflict:
             print "0x00 ------------ <><> is conflict; calling _rename_conflicted_file... %r %r" % (abspath_u, replacement_path_u)
@@ -525,7 +527,7 @@ class Downloader(QueueMixin, WriteFileMixin):
     REMOTE_SCAN_INTERVAL = 3  # facilitates tests
 
     def __init__(self, client, local_path_u, db, collective_dirnode,
-                 upload_readonly_dircap, clock, is_upload_pending):
+                 upload_readonly_dircap, clock, is_upload_pending, umask = 0123):
         QueueMixin.__init__(self, client, local_path_u, db, 'downloader', clock)
 
         if not IDirectoryNode.providedBy(collective_dirnode):
@@ -538,7 +540,7 @@ class Downloader(QueueMixin, WriteFileMixin):
         self._collective_dirnode = collective_dirnode
         self._upload_readonly_dircap = upload_readonly_dircap
         self._is_upload_pending = is_upload_pending
-
+        self._umask = umask
         self._turn_delay = self.REMOTE_SCAN_INTERVAL
 
     def start_scanning(self):
index ede36e187f69290dce9393c4c5ff63d611447a8f..8a8fb04521f2cad319ae383dfdfdc0c2d6376363 100644 (file)
@@ -1118,6 +1118,7 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase):
                 pass
 
         writefile = TestWriteFileMixin()
+        writefile._umask = 0123
 
         # create a file with name "foobar" with content "foo"
         # write downloaded file content "bar" into "foobar" with is_conflict = False