From 08c5c0fd36d4a6beedea8b03a11f76acdf543521 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 19 Feb 2022 18:40:29 +0100 Subject: zfssnap: ... --- modules/zfssnap/zfssnap.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py index e90ed0db..ef125703 100644 --- a/modules/zfssnap/zfssnap.py +++ b/modules/zfssnap/zfssnap.py @@ -76,13 +76,12 @@ def prune(config, dry_run, keep_newest): KeptBecause = namedtuple('KeptBecause', ['rule', 'ix', 'base', 'period']) kept_because = OrderedDict(deque) def keep_because(base, snap, rule, period=None): - nonlocal kept_count - if snap not in keep: - kept_count[rule][base] += 1 - if snap not in kept_because: - kept_because[snap] = deque() - kept_because[snap].append(KeptBecause(rule=rule, ix=kept_count[rule][base], base=base, period=period)) - keep.add(snap) + nonlocal KeptBecause, keep, kept_count, kept_because + kept_count[rule][base] += 1 + if snap not in kept_because: + kept_because[snap] = deque() + kept_because[snap].append(KeptBecause(rule=rule, ix=kept_count[rule][base], base=base, period=period)) + keep.add(snap) within = config.gettimedelta('KEEP', 'within') if within > timedelta(seconds=0): -- cgit v1.2.3