mirror of
https://github.com/borgbackup/borg.git
synced 2026-05-28 04:03:21 -04:00
Manifest: Make sure manifest timestamp is strictly monotonically increasing.
Computer clocks are often not set very accurately set, but borg
assumes manifest timestamps are never going back in time.
Ensure that this is actually the case.
# Conflicts:
# src/borg/helpers.py
Original-Commit: 6b8cf0a
This commit is contained in:
parent
ab52ce38f3
commit
32e73e8c7e
1 changed files with 8 additions and 1 deletions
|
|
@ -200,6 +200,7 @@ class Manifest:
|
|||
self.repository = repository
|
||||
self.item_keys = frozenset(item_keys) if item_keys is not None else ITEM_KEYS
|
||||
self.tam_verified = False
|
||||
self.timestamp = None
|
||||
|
||||
@property
|
||||
def id_str(self):
|
||||
|
|
@ -245,7 +246,13 @@ class Manifest:
|
|||
from .item import ManifestItem
|
||||
if self.key.tam_required:
|
||||
self.config[b'tam_required'] = True
|
||||
self.timestamp = datetime.utcnow().isoformat()
|
||||
# self.timestamp needs to be strictly monotonically increasing. Clocks often are not set correctly
|
||||
if self.timestamp is None:
|
||||
self.timestamp = datetime.utcnow().isoformat()
|
||||
else:
|
||||
prev_ts = datetime.strptime(self.timestamp, "%Y-%m-%dT%H:%M:%S.%f")
|
||||
incremented = (prev_ts + timedelta(microseconds=1)).isoformat()
|
||||
self.timestamp = max(incremented, datetime.utcnow().isoformat())
|
||||
manifest = ManifestItem(
|
||||
version=1,
|
||||
archives=StableDict(self.archives.get_raw_dict()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue