From 7cb6ca9641fdc8ab11ea0f247c65f8dcb6907f05 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 20 Feb 2023 13:04:39 +0000 Subject: [PATCH] feature(backups): throw an error if repo init fails --- selfprivacy_api/backup/restic_backuper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/selfprivacy_api/backup/restic_backuper.py b/selfprivacy_api/backup/restic_backuper.py index 7980e46..5cf99cd 100644 --- a/selfprivacy_api/backup/restic_backuper.py +++ b/selfprivacy_api/backup/restic_backuper.py @@ -86,11 +86,15 @@ class ResticBackuper(AbstractBackuper): repo_name, "init", ) - subprocess.Popen( + with subprocess.Popen( init_command, shell=False, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - ) + ) as process_handle: + output = process_handle.communicate()[0].decode("utf-8") + if not "created restic repository" in output: + raise ValueError("cannot init a repo: " + output) def restore_from_backup(self, repo_name, snapshot_id, folder): """