From 96b155800a63be9cd30254eb6091194c5f9c5c35 Mon Sep 17 00:00:00 2001 From: derrod Date: Sun, 18 Jun 2023 00:11:18 +0200 Subject: [PATCH] [downloader] Check if files exist before running analysis This allows additional SDL tags to be installed without going through a repair. It will also now redownload deleted files if there's an update rather than just trusting what the old manifest says should be installed locally. --- legendary/downloader/mp/manager.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/legendary/downloader/mp/manager.py b/legendary/downloader/mp/manager.py index 38b4449..a60cb08 100644 --- a/legendary/downloader/mp/manager.py +++ b/legendary/downloader/mp/manager.py @@ -137,6 +137,24 @@ class DLManager(Process): except Exception as e: self.log.warning(f'Reading resume file failed: {e!r}, continuing as normal...') + elif resume: + # Basic check if files exist locally, put all missing files into "added" + # This allows new SDL tags to be installed without having to do a repair as well. + missing_files = set() + + for fm in manifest.file_manifest_list.elements: + if fm.filename in mc.added: + continue + + local_path = os.path.join(self.dl_dir, fm.filename) + if not os.path.exists(local_path): + missing_files.add(fm.filename) + + self.log.info(f'Found {len(missing_files)} missing files.') + mc.added |= missing_files + mc.changed -= missing_files + mc.unchanged -= missing_files + # Install tags are used for selective downloading, e.g. for language packs additional_deletion_tasks = [] if file_install_tag is not None: