about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-01 19:25:07 +0100
committerhut <hut@lavabit.com>2010-01-01 19:25:07 +0100
commitd955e3f04a2b0509e8053a15a1f916bfb5677af2 (patch)
treed7a78eb532e71ec69055cd6738b34ea094506e1c
parent7d6389d61aa56db355033166b415dd0b83dabff9 (diff)
downloadranger-d955e3f04a2b0509e8053a15a1f916bfb5677af2.tar.gz
bookmarks: fixed disappearing bookmarks
-rw-r--r--TODO2
-rw-r--r--ranger/container/bookmarks.py12
2 files changed, 9 insertions, 5 deletions
diff --git a/TODO b/TODO
index cf99c122..3e1d5c8a 100644
--- a/TODO
+++ b/TODO
@@ -24,6 +24,6 @@ General
 
 Bugs
 
-   ( ) #17  10/01/01  why do bookmarks disappear sometimes?
+   (X) #17  10/01/01  why do bookmarks disappear sometimes?
    ( ) #18  10/01/01  fix notify widget (by adding a LogView?)
    (X) #19  10/01/01  resizing after pressing g
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py
index 854758bd..738efe46 100644
--- a/ranger/container/bookmarks.py
+++ b/ranger/container/bookmarks.py
@@ -35,7 +35,7 @@ class Bookmarks(object):
 		except OSError:
 			return
 
-		self._set_dict(new_dict)
+		self._set_dict(new_dict, original=new_dict)
 
 	def delete(self, key):
 		"""Delete the bookmark with the given key"""
@@ -93,6 +93,7 @@ class Bookmarks(object):
 		
 		try:
 			real_dict = self._load_dict()
+			real_dict_copy = real_dict.copy()
 		except OSError:
 			return
 
@@ -120,7 +121,7 @@ class Bookmarks(object):
 			else:
 				real_dict[key] = current
 
-		self._set_dict(real_dict)
+		self._set_dict(real_dict, original=real_dict_copy)
 
 	def save(self):
 		"""Save the bookmarks to the bookmarkfile.
@@ -156,10 +157,13 @@ class Bookmarks(object):
 		else:
 			raise OSError('Cannot read the given path')
 	
-	def _set_dict(self, dct):
+	def _set_dict(self, dct, original):
+		if original is None:
+			original = {}
+
 		self.dct.clear()
 		self.dct.update(dct)
-		self.original_dict = self.dct.copy()
+		self.original_dict = original
 		self._update_mtime()
 
 	def _get_mtime(self):