about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorigoyak <nigoyak@gmail.com>2015-06-26 16:53:26 +0200
committerigoyak <nigoyak@gmail.com>2015-06-26 17:01:56 +0200
commit2922f61c1c02803c82e725469764ecd3471ee7a6 (patch)
treeedd54e5d7403acbdb509cff8d7ebea4a207e7bde
parentdb7c728b71bce950b4683dca16d85fbc55bd2c42 (diff)
downloadranger-2922f61c1c02803c82e725469764ecd3471ee7a6.tar.gz
preserve permissions when updating bookmarks. Fix for #59
-rw-r--r--ranger/container/bookmarks.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py
index 5f163e89..cbb95864 100644
--- a/ranger/container/bookmarks.py
+++ b/ranger/container/bookmarks.py
@@ -156,6 +156,12 @@ class Bookmarks(object):
                         pass
 
             f.close()
+            old_perms = os.stat(self.path)
+            try:
+                os.chown(self.path+".new", old_perms.st_uid, old_perms.st_gid)
+                os.chmod(self.path+".new", old_perms.st_mode)
+            except OSError:
+                pass
             os.rename(self.path+".new", self.path)
         self._update_mtime()