From a44e131661525c9f17eab7db046129073defb61c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 7 May 2016 21:03:31 +0200 Subject: [PATCH] prune: fix IndexError if giving --prefix resulted in an empty archives_checkpoints list, it crashed with an IndexError. --- borg/archiver.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 42c6e4212..448187e04 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -789,9 +789,8 @@ def do_prune(self, args, repository, manifest, key): is_checkpoint = re.compile(r'\.checkpoint(\.\d+)?$').search checkpoints = [arch for arch in archives_checkpoints if is_checkpoint(arch.name)] # keep the latest checkpoint, if there is no later non-checkpoint archive - latest_checkpoint = checkpoints[0] if checkpoints else None - if archives_checkpoints[0] is latest_checkpoint: - keep_checkpoints = [latest_checkpoint, ] + if archives_checkpoints and checkpoints and archives_checkpoints[0] is checkpoints[0]: + keep_checkpoints = checkpoints[:1] else: keep_checkpoints = [] checkpoints = set(checkpoints)