1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

fix data save

This commit is contained in:
William Ting 2013-12-30 18:13:52 -06:00
parent 9811922a77
commit e5a97294ac

View File

@ -136,11 +136,11 @@ def save(config, data):
print("Error saving autojump data (disk full?)" % ex, file=sys.stderr) print("Error saving autojump data (disk full?)" % ex, file=sys.stderr)
sys.exit(1) sys.exit(1)
# move temp_file -> autojump.txt
move_file(config['tmp_path'], config['data_path'])
# create backup file if it doesn't exist or is older than BACKUP_THRESHOLD # create backup file if it doesn't exist or is older than BACKUP_THRESHOLD
if not os.path.exists(config['backup_path']) or \ if not os.path.exists(config['backup_path']) or \
(time() - os.path.getmtime(config['backup_path']) (time() - os.path.getmtime(config['backup_path'])
> BACKUP_THRESHOLD): > BACKUP_THRESHOLD):
move_file(config['data_path'], config['backup_path']) shutil.copy(config['data_path'], config['backup_path'])
# move temp_file -> autojump.txt
move_file(config['tmp_path'], config['data_path'])