From 73e15ac4a317a4f13a88693b36c10c2dfb2b774a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 7 Feb 2016 02:35:31 +0100 Subject: [PATCH] fix missing time_end metadata in old archives, fix updating end time --- borg/archive.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/borg/archive.py b/borg/archive.py index aaa907b34..52907e33c 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -179,12 +179,15 @@ def load(self, id): @property def ts(self): """Timestamp of archive creation (start) in UTC""" - return parse_timestamp(self.metadata[b'time']) + ts = self.metadata[b'time'] + return parse_timestamp(ts) @property def ts_end(self): """Timestamp of archive creation (end) in UTC""" - return parse_timestamp(self.metadata[b'time_end']) + # fall back to time if there is no time_end present in metadata + ts = self.metadata.get(b'time_end') or self.metadata[b'time'] + return parse_timestamp(ts) @property def fpr(self): @@ -231,9 +234,11 @@ def save(self, name=None, timestamp=None): raise self.AlreadyExists(name) self.items_buffer.flush(flush=True) if timestamp is None: + self.end = datetime.utcnow() start = self.start end = self.end else: + self.end = timestamp start = timestamp end = timestamp # we only have 1 value metadata = StableDict({