Skip to content

Commit

Permalink
[downloader] Check if files exist before running analysis
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derrod committed Jun 17, 2023
1 parent 4145381 commit 96b1558
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions legendary/downloader/mp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ def run_analysis(self, manifest: Manifest, old_manifest: Manifest = None,
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:
Expand Down

0 comments on commit 96b1558

Please sign in to comment.