From 8f2eea2840fbe1a041b6ceb4bb5f463c8c7a8f76 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 4 Apr 2020 20:09:32 +0200 Subject: [PATCH] backend: Make sure that initialize initializes the metadata --- backup/backup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backup/backup.py b/backup/backup.py index 8e017a9..b39b81e 100755 --- a/backup/backup.py +++ b/backup/backup.py @@ -40,6 +40,8 @@ class Backend(object): - backend.prev_version: the previous data version in case we need to roll back the last one """ + self.version = None + self.prev_version = None raise NotImplementedError def add_change(self, change: Change) -> bool: @@ -88,6 +90,8 @@ class FileBackend(Backend): def initialize(self) -> bool: if not os.path.exists(self.url.path): + self.version = 0 + self.prev_version = 0 return False return self.read_metadata() @@ -170,7 +174,11 @@ def get_backend(destination): raise ValueError("No backend implementation found for {destination}".format( destination=destination, )) - return backend_cl(destination) + backend = backend_cl(destination) + backend.initialize() + assert(backend.version is not None) + assert(backend.prev_version is not None) + return backend def abort(reason: str) -> None: