|
@@ -306,15 +306,25 @@ def collect_special_file_paths(
|
|
|
)
|
|
|
|
|
|
|
|
|
-def check_all_source_directories_exist(source_directories):
|
|
|
+def check_all_source_directories_exist(source_directories, working_directory=None):
|
|
|
'''
|
|
|
- Given a sequence of source directories, check that they all exist. If any do not, raise an
|
|
|
- exception.
|
|
|
+ Given a sequence of source directories and an optional working directory to serve as a prefix
|
|
|
+ for each (if it's a relative directory), check that the source directories all exist. If any do
|
|
|
+ not, raise an exception.
|
|
|
'''
|
|
|
missing_directories = [
|
|
|
source_directory
|
|
|
for source_directory in source_directories
|
|
|
- if not all([os.path.exists(directory) for directory in expand_directory(source_directory)])
|
|
|
+ if not all(
|
|
|
+ [
|
|
|
+ os.path.exists(directory)
|
|
|
+ for directory in expand_directory(
|
|
|
+ os.path.join(working_directory, source_directory)
|
|
|
+ if working_directory
|
|
|
+ else source_directory
|
|
|
+ )
|
|
|
+ ]
|
|
|
+ )
|
|
|
]
|
|
|
if missing_directories:
|
|
|
raise ValueError(f"Source directories do not exist: {', '.join(missing_directories)}")
|
|
@@ -342,8 +352,15 @@ def make_base_create_command(
|
|
|
(base Borg create command flags, Borg create command positional arguments, open pattern file
|
|
|
handle, open exclude file handle).
|
|
|
'''
|
|
|
+ try:
|
|
|
+ working_directory = os.path.expanduser(config.get('working_directory'))
|
|
|
+ except TypeError:
|
|
|
+ working_directory = None
|
|
|
+
|
|
|
if config.get('source_directories_must_exist', False):
|
|
|
- check_all_source_directories_exist(config.get('source_directories'))
|
|
|
+ check_all_source_directories_exist(
|
|
|
+ config.get('source_directories'), working_directory=working_directory
|
|
|
+ )
|
|
|
|
|
|
sources = deduplicate_directories(
|
|
|
map_directories_to_devices(
|
|
@@ -445,11 +462,6 @@ def make_base_create_command(
|
|
|
logger.warning(
|
|
|
f'{repository_path}: Ignoring configured "read_special" value of false, as true is needed for database hooks.'
|
|
|
)
|
|
|
- try:
|
|
|
- working_directory = os.path.expanduser(config.get('working_directory'))
|
|
|
- except TypeError:
|
|
|
- working_directory = None
|
|
|
-
|
|
|
borg_environment = environment.make_environment(config)
|
|
|
|
|
|
logger.debug(f'{repository_path}: Collecting special file paths')
|