[elbe-devel] [PATCH 2/7] Fix None case for Filesystem write_file/append_file mode

dion at linutronix.de dion at linutronix.de
Fri May 17 11:16:56 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>
---
 elbepack/filesystem.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 5d8c8cea..cc7d08f5 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -152,13 +152,14 @@ 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")
         f.write(content)
         f.close()
-        if mode is not None
+        if mode is not None:
             self.chmod(path, mode)
 
     def read_file(self, path):
-- 
2.21.0




More information about the elbe-devel mailing list