mirror of https://github.com/borgbackup/borg.git
Handle case of calling prune_split when there are no archives
This commit is contained in:
parent
5b050bd01c
commit
663abc7c90
|
@ -49,6 +49,8 @@ def prune_split(archives, rule, n, kept_because=None):
|
||||||
kept_because = {}
|
kept_because = {}
|
||||||
if n == 0:
|
if n == 0:
|
||||||
return keep
|
return keep
|
||||||
|
|
||||||
|
a = None
|
||||||
for a in sorted(archives, key=attrgetter('ts'), reverse=True):
|
for a in sorted(archives, key=attrgetter('ts'), reverse=True):
|
||||||
period = to_localtime(a.ts).strftime(pattern)
|
period = to_localtime(a.ts).strftime(pattern)
|
||||||
if period != last:
|
if period != last:
|
||||||
|
@ -59,7 +61,7 @@ def prune_split(archives, rule, n, kept_because=None):
|
||||||
if len(keep) == n:
|
if len(keep) == n:
|
||||||
break
|
break
|
||||||
# Keep oldest archive if we didn't reach the target retention count
|
# Keep oldest archive if we didn't reach the target retention count
|
||||||
if len(keep) < n and a.id not in kept_because:
|
if a is not None and len(keep) < n and a.id not in kept_because:
|
||||||
keep.append(a)
|
keep.append(a)
|
||||||
kept_because[a.id] = (rule+"[oldest]", len(keep))
|
kept_because[a.id] = (rule+"[oldest]", len(keep))
|
||||||
return keep
|
return keep
|
||||||
|
|
Loading…
Reference in New Issue