浏览代码

Merge pull request #7282 from ThomasWaldmann/prune-in-utc

prune: compute pruning in utc timezone
TW 2 年之前
父节点
当前提交
4664176e87
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/borg/archiver/prune_cmd.py

+ 4 - 2
src/borg/archiver/prune_cmd.py

@@ -53,8 +53,10 @@ def prune_split(archives, rule, n, kept_because=None):
 
 
     a = None
     a = None
     for a in sorted(archives, key=attrgetter("ts"), reverse=True):
     for a in sorted(archives, key=attrgetter("ts"), reverse=True):
-        # we compute the pruning in local time zone
-        period = a.ts.astimezone().strftime(pattern)
+        # we compute the pruning in UTC time zone
+        # note: we used to compute the pruning in local timezone (tz=None),
+        # but this is causing test failures in some time zones (like e.g. UTC+12).
+        period = a.ts.astimezone(tz=timezone.utc).strftime(pattern)
         if period != last:
         if period != last:
             last = period
             last = period
             if a.id not in kept_because:
             if a.id not in kept_because: