mirror of https://github.com/borgbackup/borg.git
Adding try/finally block to make sure cleanup happens
This commit is contained in:
parent
155d58d297
commit
3b0bafc82f
|
@ -456,6 +456,7 @@ class Archiver:
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def test_files(path, count, size, random):
|
def test_files(path, count, size, random):
|
||||||
|
try:
|
||||||
path = os.path.join(path, 'borg-test-data')
|
path = os.path.join(path, 'borg-test-data')
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
z_buff = None if random else memoryview(zeros)[:size] if size <= len(zeros) else b'\0' * size
|
z_buff = None if random else memoryview(zeros)[:size] if size <= len(zeros) else b'\0' * size
|
||||||
|
@ -465,6 +466,7 @@ class Archiver:
|
||||||
with SyncFile(fname, binary=True) as fd: # used for posix_fadvise's sake
|
with SyncFile(fname, binary=True) as fd: # used for posix_fadvise's sake
|
||||||
fd.write(data)
|
fd.write(data)
|
||||||
yield path
|
yield path
|
||||||
|
finally:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
if '_BORG_BENCHMARK_CRUD_TEST' in os.environ:
|
if '_BORG_BENCHMARK_CRUD_TEST' in os.environ:
|
||||||
|
|
Loading…
Reference in New Issue