From 0db137efdfd785eb403d8531a47fb17637c9296c Mon Sep 17 00:00:00 2001 From: Soumik Dutta Date: Sat, 18 Mar 2023 01:48:24 +0530 Subject: [PATCH 1/2] add option to set borg_files_cache_ttl in config Signed-off-by: Soumik Dutta --- borgmatic/borg/environment.py | 3 ++- borgmatic/config/schema.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/borgmatic/borg/environment.py b/borgmatic/borg/environment.py index 235c674d..1b14369a 100644 --- a/borgmatic/borg/environment.py +++ b/borgmatic/borg/environment.py @@ -2,6 +2,7 @@ OPTION_TO_ENVIRONMENT_VARIABLE = { 'borg_base_directory': 'BORG_BASE_DIR', 'borg_config_directory': 'BORG_CONFIG_DIR', 'borg_cache_directory': 'BORG_CACHE_DIR', + 'borg_files_cache_ttl': 'BORG_FILES_CACHE_TTL', 'borg_security_directory': 'BORG_SECURITY_DIR', 'borg_keys_directory': 'BORG_KEYS_DIR', 'encryption_passcommand': 'BORG_PASSCOMMAND', @@ -27,7 +28,7 @@ def make_environment(storage_config): value = storage_config.get(option_name) if value: - environment[environment_variable_name] = value + environment[environment_variable_name] = str(value) for ( option_name, diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index f7161563..af0051b7 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -315,6 +315,12 @@ properties: Path for Borg cache files. Defaults to $borg_base_directory/.cache/borg example: /path/to/base/cache + borg_files_cache_ttl: + type: integer + description: | + Maximum time to live (ttl) for entries in the borg files + cache. + example: 20 borg_security_directory: type: string description: | From fb9677230bb66af2f1b6175b52fd29a217f252dc Mon Sep 17 00:00:00 2001 From: Soumik Dutta Date: Sat, 18 Mar 2023 02:57:56 +0530 Subject: [PATCH 2/2] add test to ensure integers are converted to string before setting them up to be environment variable values Signed-off-by: Soumik Dutta --- borgmatic/config/schema.yaml | 2 +- tests/unit/borg/test_environment.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index af0051b7..2cb6dbb3 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -318,7 +318,7 @@ properties: borg_files_cache_ttl: type: integer description: | - Maximum time to live (ttl) for entries in the borg files + Maximum time to live (ttl) for entries in the Borg files cache. example: 20 borg_security_directory: diff --git a/tests/unit/borg/test_environment.py b/tests/unit/borg/test_environment.py index c5fce80d..4cef39b9 100644 --- a/tests/unit/borg/test_environment.py +++ b/tests/unit/borg/test_environment.py @@ -32,3 +32,8 @@ def test_make_environment_with_relocated_repo_access_should_override_default(): environment = module.make_environment({'relocated_repo_access_is_ok': True}) assert environment.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes' + + +def test_make_environment_with_integer_variable_value(): + environment = module.make_environment({'borg_files_cache_ttl': 40}) + assert environment.get('BORG_FILES_CACHE_TTL') == '40'