mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Automatically recover from db corruption. Thanks epall!!!
This commit is contained in:
parent
0ec15907e3
commit
2d4e3c8a6c
5
autojump
5
autojump
@ -18,7 +18,7 @@
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
import cPickle
|
import cPickle
|
||||||
import getopt
|
import getopt
|
||||||
from sys import argv,exit
|
from sys import argv,exit,stderr
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
max_keyweight=1000
|
max_keyweight=1000
|
||||||
@ -84,8 +84,9 @@ def open_dic(dic_file,error_recovery=False):
|
|||||||
path_dict=cPickle.load(aj_file)
|
path_dict=cPickle.load(aj_file)
|
||||||
aj_file.close()
|
aj_file.close()
|
||||||
return path_dict
|
return path_dict
|
||||||
except (IOError,EOFError):
|
except (IOError,EOFError,cPickle.UnpicklingError):
|
||||||
if not error_recovery and os.path.exists(dic_file+".bak"):
|
if not error_recovery and os.path.exists(dic_file+".bak"):
|
||||||
|
print >> stderr, 'Problem with autojump database, trying to recover from backup...'
|
||||||
import shutil
|
import shutil
|
||||||
shutil.copy(dic_file+".bak",dic_file)
|
shutil.copy(dic_file+".bak",dic_file)
|
||||||
return open_dic(dic_file,True)
|
return open_dic(dic_file,True)
|
||||||
|
Loading…
Reference in New Issue
Block a user