From d44214f136900933f858f8b8b8234e6dd48e5ac4 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 5 Aug 2015 17:30:21 +0300 Subject: [PATCH] Prevent the autorestore to recover backups on non-existent files --- rc/autorestore.kak | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rc/autorestore.kak b/rc/autorestore.kak index daa989f2..8956a5ac 100644 --- a/rc/autorestore.kak +++ b/rc/autorestore.kak @@ -7,6 +7,8 @@ def autorestore-restore-buffer -docstring "Restore the backup for the current fi buffer_basename="${kak_bufname##*/}" buffer_dirname=$(dirname "${kak_bufname}") + test ! -f "${kak_bufname}" && exit + ## Find the name of the latest backup created for the buffer that was open ## The backup file has to have been last modified more recently than the file we are editing latest_backup_path=$(find "${buffer_dirname}" -maxdepth 1 -type f -readable -newer "${kak_bufname}" -name "\.${buffer_basename}\.kak\.*" -printf '%A@/%p\n' 2>/dev/null \ @@ -45,6 +47,8 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current buffer_basename="${kak_bufname##*/}" buffer_dirname=$(dirname "${kak_bufname}") + test ! -f "${kak_bufname}" && exit + find "${buffer_dirname}" -maxdepth 1 -type f -readable -name "\.${buffer_basename}\.kak\.*" -delete 2>/dev/null } echo -color 'Information Backup files removed'