2023-01-26 07:31:07 +00:00
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import borgmatic.borg.list
|
|
|
|
import borgmatic.config.validate
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def run_list(
|
2023-04-15 02:35:24 +00:00
|
|
|
repository,
|
|
|
|
storage,
|
|
|
|
local_borg_version,
|
|
|
|
list_arguments,
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments,
|
2023-04-15 02:35:24 +00:00
|
|
|
local_path,
|
|
|
|
remote_path,
|
2023-01-26 07:31:07 +00:00
|
|
|
):
|
|
|
|
'''
|
|
|
|
Run the "list" action for the given repository and archive.
|
|
|
|
|
|
|
|
If list_arguments.json is True, yield the JSON output from listing the archive.
|
|
|
|
'''
|
|
|
|
if list_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
|
|
|
repository, list_arguments.repository
|
|
|
|
):
|
|
|
|
if not list_arguments.json: # pragma: nocover
|
|
|
|
if list_arguments.find_paths:
|
2023-03-24 19:34:57 +00:00
|
|
|
logger.answer(f'{repository["path"]}: Searching archives')
|
2023-01-26 07:31:07 +00:00
|
|
|
elif not list_arguments.archive:
|
2023-03-24 19:34:57 +00:00
|
|
|
logger.answer(f'{repository["path"]}: Listing archives')
|
2023-01-26 07:31:07 +00:00
|
|
|
list_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
|
2023-03-24 19:34:57 +00:00
|
|
|
repository['path'],
|
2023-01-26 07:31:07 +00:00
|
|
|
list_arguments.archive,
|
|
|
|
storage,
|
|
|
|
local_borg_version,
|
2023-05-09 06:00:49 +00:00
|
|
|
global_arguments,
|
2023-01-26 07:31:07 +00:00
|
|
|
local_path,
|
|
|
|
remote_path,
|
|
|
|
)
|
|
|
|
json_output = borgmatic.borg.list.list_archive(
|
2023-03-24 19:34:57 +00:00
|
|
|
repository['path'],
|
2023-01-26 07:31:07 +00:00
|
|
|
storage,
|
|
|
|
local_borg_version,
|
2023-05-09 06:00:49 +00:00
|
|
|
list_arguments,
|
|
|
|
global_arguments,
|
|
|
|
local_path,
|
|
|
|
remote_path,
|
2023-01-26 07:31:07 +00:00
|
|
|
)
|
|
|
|
if json_output: # pragma: nocover
|
|
|
|
yield json.loads(json_output)
|