From 2d4e3c8a6cd4d85b57e7c10ac0320e9014d0e265 Mon Sep 17 00:00:00 2001 From: Joel Schaerer Date: Sat, 3 Oct 2009 20:36:18 +0200 Subject: [PATCH] Automatically recover from db corruption. Thanks epall!!! --- autojump | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autojump b/autojump index 18ca13d..bcb617c 100755 --- a/autojump +++ b/autojump @@ -18,7 +18,7 @@ from __future__ import division import cPickle import getopt -from sys import argv,exit +from sys import argv,exit,stderr import os import signal max_keyweight=1000 @@ -84,8 +84,9 @@ def open_dic(dic_file,error_recovery=False): path_dict=cPickle.load(aj_file) aj_file.close() return path_dict - except (IOError,EOFError): + except (IOError,EOFError,cPickle.UnpicklingError): if not error_recovery and os.path.exists(dic_file+".bak"): + print >> stderr, 'Problem with autojump database, trying to recover from backup...' import shutil shutil.copy(dic_file+".bak",dic_file) return open_dic(dic_file,True)