[cwconfig] add the CubicWebConfiguration.ensure_uid_directory() method (related to #11298794) 3.22
authorDavid Douard <david.douard@logilab.fr>
Tue, 19 Jul 2016 19:50:48 +0200
branch3.22
changeset 11436 dca6ae982ee5
parent 11435 42578bc0b5ef
child 11437 dbe73990172b
[cwconfig] add the CubicWebConfiguration.ensure_uid_directory() method (related to #11298794) that recursively enforce uid on files.
cwconfig.py
--- a/cwconfig.py	Tue Jul 19 19:26:20 2016 +0200
+++ b/cwconfig.py	Tue Jul 19 19:50:48 2016 +0200
@@ -1114,7 +1114,15 @@
             except OSError as ex:
                 self.warning('error while forcing write permission on %s: %s',
                              path, ex)
-    
+
+    def ensure_uid_directory(self, path, enforce_write=False):
+        self.check_writeable_uid_directory(path)
+
+        def cb(arg, dirname, fnames):
+            for name in fnames:
+                self.ensure_uid(join(dirname, name), enforce_write)
+        os.path.walk(path, cb, None)
+        return path
 
     @cached
     def instance_md5_version(self):