From d906fbc4bb4ccfc6d1ac32fe600bcae34d548737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 5 Jan 2021 03:31:09 +0100 Subject: [PATCH] backup: add function parameter for override temp directory This will be useful for tests. QubesOS/qubes-issues# --- qubesadmin/backup/restore.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qubesadmin/backup/restore.py b/qubesadmin/backup/restore.py index 890fb96..6993191 100644 --- a/qubesadmin/backup/restore.py +++ b/qubesadmin/backup/restore.py @@ -20,6 +20,7 @@ '''Backup restore module''' +import contextlib import errno import fcntl import functools @@ -910,7 +911,8 @@ class BackupRestore(object): self.username = os.path.basename(subdir) def __init__(self, app, backup_location, backup_vm, passphrase, - location_is_service=False, force_compression_filter=None): + location_is_service=False, force_compression_filter=None, + tmpdir="/var/tmp"): super().__init__() #: qubes.Qubes instance @@ -940,7 +942,7 @@ class BackupRestore(object): #: temporary directory used to extract the data before moving to the # final location - self.tmpdir = tempfile.mkdtemp(prefix="restore", dir="/var/tmp") + self.tmpdir = tempfile.mkdtemp(prefix="restore", dir=tmpdir) #: list of processes (Popen objects) to kill on cancel self.processes_to_kill_on_cancel = []