From b0cad58d6c67e8081d9b3caa7f1e77ea6935b2d5 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 16 Nov 2024 11:26:24 -0800 Subject: [PATCH] Add a dash to the prefix of the randomly named temporary directory to improve readability (#937). --- borgmatic/config/paths.py | 3 ++- tests/unit/config/test_paths.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/borgmatic/config/paths.py b/borgmatic/config/paths.py index 144222f1..19bb9d95 100644 --- a/borgmatic/config/paths.py +++ b/borgmatic/config/paths.py @@ -70,7 +70,8 @@ class Runtime_directory: self.temporary_directory = None else: self.temporary_directory = tempfile.TemporaryDirectory( - prefix='borgmatic', dir=os.environ.get('TMPDIR') or os.environ.get('TEMP') or '/tmp' + prefix='borgmatic-', + dir=os.environ.get('TMPDIR') or os.environ.get('TEMP') or '/tmp', ) runtime_directory = self.temporary_directory.name diff --git a/tests/unit/config/test_paths.py b/tests/unit/config/test_paths.py index a6b6892c..5a8e674d 100644 --- a/tests/unit/config/test_paths.py +++ b/tests/unit/config/test_paths.py @@ -101,7 +101,7 @@ def test_runtime_directory_falls_back_to_tmpdir_and_adds_temporary_subdirectory_ temporary_directory = flexmock(name='/run/borgmatic-1234') temporary_directory.should_receive('cleanup').once() flexmock(module.tempfile).should_receive('TemporaryDirectory').with_args( - prefix='borgmatic', dir='/run' + prefix='borgmatic-', dir='/run' ).and_return(temporary_directory) with module.Runtime_directory({}) as borgmatic_runtime_directory: @@ -119,7 +119,7 @@ def test_runtime_directory_falls_back_to_temp_and_adds_temporary_subdirectory_th temporary_directory = flexmock(name='/run/borgmatic-1234') temporary_directory.should_receive('cleanup').once() flexmock(module.tempfile).should_receive('TemporaryDirectory').with_args( - prefix='borgmatic', dir='/run' + prefix='borgmatic-', dir='/run' ).and_return(temporary_directory) with module.Runtime_directory({}) as borgmatic_runtime_directory: @@ -137,7 +137,7 @@ def test_runtime_directory_falls_back_to_hard_coded_tmp_path_and_adds_temporary_ temporary_directory = flexmock(name='/tmp/borgmatic-1234') temporary_directory.should_receive('cleanup').once() flexmock(module.tempfile).should_receive('TemporaryDirectory').with_args( - prefix='borgmatic', dir='/tmp' + prefix='borgmatic-', dir='/tmp' ).and_return(temporary_directory) with module.Runtime_directory({}) as borgmatic_runtime_directory: