summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-03-08 03:43:13 +0000
committerhut <hut@lavabit.com>2011-03-08 03:43:13 +0000
commitca4b999c016a9e1524e8ac268d87b668927afbfb (patch)
treebcc000eb9472e243ea182d2d439d67ac01ffeb4d
parentb7b8f3a081c03000e3c4d4e6da943516c9848c31 (diff)
downloadranger-ca4b999c016a9e1524e8ac268d87b668927afbfb.tar.gz
Fix loss of bookmarks when disk is full
-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):