From 4343c2f00ca9d86be8579d403c4bc12dcd60b96d Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 8 Mar 2011 03:43:13 +0000 Subject: Fix loss of bookmarks when disk is full --- ranger/container/bookmarks.py | 5 +++-- 1 file 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): -- cgit 1.4.1-2-gfad0