From ba0899660dd3e1bfd0ee6264c7001885719efc42 Mon Sep 17 00:00:00 2001 From: Felix Kaechele Date: Sat, 3 Jun 2023 08:11:56 -0400 Subject: [PATCH] Verify that schema path exists before returning it Signed-off-by: Felix Kaechele --- borgmatic/config/validate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 2ed1af5..1917eea 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -11,8 +11,15 @@ def schema_filename(): ''' Path to the installed YAML configuration schema file, used to validate and parse the configuration. + + Raise FileNotFoundError when the schema path does not exist. ''' - return os.path.join(os.path.dirname(borgmatic.config.__file__), 'schema.yaml') + schema_path = os.path.join(os.path.dirname(borgmatic.config.__file__), 'schema.yaml') + + if os.path.exists(schema_path) and os.path.isfile(schema_path): + return schema_path + + raise FileNotFoundError def format_json_error_path_element(path_element):