[elbe-devel] [PATCH v3 2/6] Fix None case for Filesystem write_file mode

dion at linutronix.de dion at linutronix.de
Tue May 21 14:47:16 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Both methods 'write_file' and 'append_file' change the mode of the target
file after the operation.  But, we don't always want to change the
mode of the file.

Thus, if the mode is 'None', the file's mode is unchanged.

Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/filesystem.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 978d32a1..cc7d08f5 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -152,7 +152,8 @@ class Filesystem(object):
         f = self.open(path, "w")
         f.write(cont)
         f.close()
-        self.chmod(path, mode)
+        if mode is not None:
+            self.chmod(path, mode)
 
     def append_file(self, path, content, mode=None):
         f = self.open(path, "a")
-- 
2.21.0




More information about the elbe-devel mailing list