Skip to content

Commit

Permalink
[utils] Fix manifest combiner for delta patching
Browse files Browse the repository at this point in the history
Previously this would result in duplicated chunks,
causing calculations for download sizes to be incorrect.

Fixes #278
  • Loading branch information
derrod committed May 24, 2021
1 parent 313323e commit 7ae4eda
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions legendary/utils/manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ def combine_manifests(base_manifest: Manifest, delta_manifest: Manifest):
base_manifest.file_manifest_list.count = len(base_manifest.file_manifest_list.elements)
base_manifest.file_manifest_list._path_map = None

# add chunks from delta manifest to main manifest and again clear path caches
base_manifest.chunk_data_list.elements.extend(delta_manifest.chunk_data_list.elements)
# ensure guid map exists
try:
base_manifest.chunk_data_list.get_chunk_by_guid(0)
except:
pass

# add new chunks from delta manifest to main manifest and again clear maps and update count
existing_chunk_guids = base_manifest.chunk_data_list._guid_int_map.keys()

for chunk in delta_manifest.chunk_data_list.elements:
if chunk.guid_num not in existing_chunk_guids:
base_manifest.chunk_data_list.elements.append(chunk)

base_manifest.chunk_data_list.count = len(base_manifest.chunk_data_list.elements)
base_manifest.chunk_data_list._guid_map = None
base_manifest.chunk_data_list._guid_int_map = None
Expand Down

0 comments on commit 7ae4eda

Please sign in to comment.