backup: add function parameter for override temp directory

This will be useful for tests.

QubesOS/qubes-issues#
This commit is contained in:
Marek Marczykowski-Górecki 2021-01-05 03:31:09 +01:00
parent 25a6a305c8
commit d906fbc4bb
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -20,6 +20,7 @@
'''Backup restore module''' '''Backup restore module'''
import contextlib
import errno import errno
import fcntl import fcntl
import functools import functools
@ -910,7 +911,8 @@ class BackupRestore(object):
self.username = os.path.basename(subdir) self.username = os.path.basename(subdir)
def __init__(self, app, backup_location, backup_vm, passphrase, 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__() super().__init__()
#: qubes.Qubes instance #: qubes.Qubes instance
@ -940,7 +942,7 @@ class BackupRestore(object):
#: temporary directory used to extract the data before moving to the #: temporary directory used to extract the data before moving to the
# final location # 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 #: list of processes (Popen objects) to kill on cancel
self.processes_to_kill_on_cancel = [] self.processes_to_kill_on_cancel = []