summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/bookmarks.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py
index 1e801638..f115c753 100644
--- a/ranger/container/bookmarks.py
+++ b/ranger/container/bookmarks.py
@@ -15,7 +15,7 @@
 
 import string
 import re
-import os.path
+import os
 ALLOWED_KEYS = string.ascii_letters + string.digits + "`'"
 
 class Bookmarks(object):
@@ -152,7 +152,7 @@ class Bookmarks(object):
 		if self.path is None:
 			return
 		if os.access(self.path, os.W_OK):
-			f = open(self.path, 'w')
+			f = open(self.path+".new", 'w')
 			for key, value in self.dct.items():
 				if type(key) == str\
 						and key in ALLOWED_KEYS:
@@ -162,6 +162,7 @@ class Bookmarks(object):
 						pass
 
 			f.close()
+			os.rename(self.path+".new", self.path)
 		self._update_mtime()
 
 	def _load_dict(self):