mirror of
https://github.com/derrod/legendary.git
synced 2024-06-02 10:44:54 +12:00
feat: download exclusions from file
This commit is contained in:
parent
f26c8ab0a1
commit
6033cab662
|
@ -807,7 +807,7 @@ class LegendaryCLI:
|
|||
logger.error('Login failed! Cannot continue with download process.')
|
||||
exit(1)
|
||||
|
||||
if args.file_prefix or args.file_exclude_prefix:
|
||||
if args.file_prefix or args.file_exclude_prefix or args.file_exclude_filelist:
|
||||
args.no_install = True
|
||||
|
||||
if args.update_only:
|
||||
|
@ -937,6 +937,7 @@ class LegendaryCLI:
|
|||
platform=args.platform,
|
||||
file_prefix_filter=args.file_prefix,
|
||||
file_exclude_filter=args.file_exclude_prefix,
|
||||
file_exclude_filelist=args.file_exclude_filelist,
|
||||
file_install_tag=args.install_tag,
|
||||
dl_optimizations=args.order_opt,
|
||||
dl_timeout=args.dl_timeout,
|
||||
|
@ -2661,6 +2662,8 @@ def main():
|
|||
help='Only fetch files whose path starts with <prefix> (case insensitive)')
|
||||
install_parser.add_argument('--exclude', dest='file_exclude_prefix', action='append', metavar='<prefix>',
|
||||
type=str, help='Exclude files starting with <prefix> (case insensitive)')
|
||||
install_parser.add_argument('--exclude-file', dest='file_exclude_filelist', action='store', metavar='<file>',
|
||||
type=str, help='Exclude files listed in <file> (case sensitive)')
|
||||
install_parser.add_argument('--install-tag', dest='install_tag', action='append', metavar='<tag>',
|
||||
type=str, help='Only download files with the specified install tag')
|
||||
install_parser.add_argument('--enable-reordering', dest='order_opt', action='store_true',
|
||||
|
|
|
@ -1233,12 +1233,13 @@ class LegendaryCore:
|
|||
game_folder: str = '', override_manifest: str = '',
|
||||
override_old_manifest: str = '', override_base_url: str = '',
|
||||
platform: str = 'Windows', file_prefix_filter: list = None,
|
||||
file_exclude_filter: list = None, file_install_tag: list = None,
|
||||
dl_optimizations: bool = False, dl_timeout: int = 10,
|
||||
repair: bool = False, repair_use_latest: bool = False,
|
||||
disable_delta: bool = False, override_delta_manifest: str = '',
|
||||
egl_guid: str = '', preferred_cdn: str = None,
|
||||
disable_https: bool = False) -> (DLManager, AnalysisResult, ManifestMeta):
|
||||
file_exclude_filter: list = None, file_exclude_filelist: str = '',
|
||||
file_install_tag: list = None, dl_optimizations: bool = False,
|
||||
dl_timeout: int = 10, repair: bool = False,
|
||||
repair_use_latest: bool = False, disable_delta: bool = False,
|
||||
override_delta_manifest: str = '', egl_guid: str = '',
|
||||
preferred_cdn: str = None, disable_https: bool = False
|
||||
) -> (DLManager, AnalysisResult, ManifestMeta):
|
||||
# load old manifest
|
||||
old_manifest = None
|
||||
|
||||
|
@ -1410,6 +1411,7 @@ class LegendaryCore:
|
|||
patch=not disable_patching, resume=not force,
|
||||
file_prefix_filter=file_prefix_filter,
|
||||
file_exclude_filter=file_exclude_filter,
|
||||
file_exclude_filelist=file_exclude_filelist,
|
||||
file_install_tag=file_install_tag,
|
||||
processing_optimization=process_opt)
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ class DLManager(Process):
|
|||
def run_analysis(self, manifest: Manifest, old_manifest: Manifest = None,
|
||||
patch=True, resume=True, file_prefix_filter=None,
|
||||
file_exclude_filter=None, file_install_tag=None,
|
||||
file_exclude_filelist=None,
|
||||
processing_optimization=False) -> AnalysisResult:
|
||||
"""
|
||||
Run analysis on manifest and old manifest (if not None) and return a result
|
||||
|
@ -166,6 +167,16 @@ class DLManager(Process):
|
|||
mc.changed -= files_to_skip
|
||||
mc.unchanged |= files_to_skip
|
||||
|
||||
if file_exclude_filelist:
|
||||
file = open(file_exclude_filelist, 'r')
|
||||
file_exclusions = set(file.read().splitlines())
|
||||
file.close()
|
||||
|
||||
self.log.info(f'Found {len(file_exclusions)} files to skip')
|
||||
mc.added -= file_exclusions
|
||||
mc.changed -= file_exclusions
|
||||
mc.unchanged |= file_exclusions
|
||||
|
||||
if file_prefix_filter:
|
||||
if isinstance(file_prefix_filter, str):
|
||||
file_prefix_filter = [file_prefix_filter]
|
||||
|
@ -178,7 +189,7 @@ class DLManager(Process):
|
|||
mc.changed -= files_to_skip
|
||||
mc.unchanged |= files_to_skip
|
||||
|
||||
if file_prefix_filter or file_exclude_filter or file_install_tag:
|
||||
if file_prefix_filter or file_exclude_filter or file_exclude_filelist or file_install_tag:
|
||||
self.log.info(f'Remaining files after filtering: {len(mc.added) + len(mc.changed)}')
|
||||
# correct install size after filtering
|
||||
analysis_res.install_size = sum(fm.file_size for fm in manifest.file_manifest_list.elements
|
||||
|
|
Loading…
Reference in a new issue