mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[core/downloader] Prevent file deletion when using delta manifest
This is technically not how we should do this. In theory we should "overlay" the delta manifest over the proper one and simply add/replace the chunk/file list entries with the one from the delta manifest. However simply not deleting files also works for the time being since files are rarely deleted anyways.
This commit is contained in:
parent
bd66d6c5dc
commit
a55f75d5e8
|
@ -662,6 +662,7 @@ class LegendaryCore:
|
||||||
) -> (DLManager, AnalysisResult, ManifestMeta):
|
) -> (DLManager, AnalysisResult, ManifestMeta):
|
||||||
# load old manifest
|
# load old manifest
|
||||||
old_manifest = None
|
old_manifest = None
|
||||||
|
delta_manifest_used = False
|
||||||
|
|
||||||
# load old manifest if we have one
|
# load old manifest if we have one
|
||||||
if override_old_manifest:
|
if override_old_manifest:
|
||||||
|
@ -711,6 +712,7 @@ class LegendaryCore:
|
||||||
f'"{old_manifest.meta.build_id}" to'
|
f'"{old_manifest.meta.build_id}" to'
|
||||||
f'"{new_manifest.meta.build_id}"...')
|
f'"{new_manifest.meta.build_id}"...')
|
||||||
new_manifest = delta_manifest
|
new_manifest = delta_manifest
|
||||||
|
delta_manifest_used = True
|
||||||
else:
|
else:
|
||||||
self.log.debug(f'No Delta manifest received from CDN.')
|
self.log.debug(f'No Delta manifest received from CDN.')
|
||||||
|
|
||||||
|
@ -782,7 +784,8 @@ class LegendaryCore:
|
||||||
file_prefix_filter=file_prefix_filter,
|
file_prefix_filter=file_prefix_filter,
|
||||||
file_exclude_filter=file_exclude_filter,
|
file_exclude_filter=file_exclude_filter,
|
||||||
file_install_tag=file_install_tag,
|
file_install_tag=file_install_tag,
|
||||||
processing_optimization=process_opt)
|
processing_optimization=process_opt,
|
||||||
|
delta_manifest_used=delta_manifest_used)
|
||||||
|
|
||||||
prereq = None
|
prereq = None
|
||||||
if new_manifest.meta.prereq_ids:
|
if new_manifest.meta.prereq_ids:
|
||||||
|
|
|
@ -79,7 +79,7 @@ class DLManager(Process):
|
||||||
def run_analysis(self, manifest: Manifest, old_manifest: Manifest = None,
|
def run_analysis(self, manifest: Manifest, old_manifest: Manifest = None,
|
||||||
patch=True, resume=True, file_prefix_filter=None,
|
patch=True, resume=True, file_prefix_filter=None,
|
||||||
file_exclude_filter=None, file_install_tag=None,
|
file_exclude_filter=None, file_install_tag=None,
|
||||||
processing_optimization=False) -> AnalysisResult:
|
processing_optimization=False, delta_manifest_used=False) -> AnalysisResult:
|
||||||
"""
|
"""
|
||||||
Run analysis on manifest and old manifest (if not None) and return a result
|
Run analysis on manifest and old manifest (if not None) and return a result
|
||||||
with a summary resources required in order to install the provided manifest.
|
with a summary resources required in order to install the provided manifest.
|
||||||
|
@ -92,6 +92,7 @@ class DLManager(Process):
|
||||||
:param file_exclude_filter: Exclude files with this prefix from download
|
:param file_exclude_filter: Exclude files with this prefix from download
|
||||||
:param file_install_tag: Only install files with the specified tag
|
:param file_install_tag: Only install files with the specified tag
|
||||||
:param processing_optimization: Attempt to optimize processing order and RAM usage
|
:param processing_optimization: Attempt to optimize processing order and RAM usage
|
||||||
|
:param delta_manifest_used: whether or not the manifest is a delta manifest
|
||||||
:return: AnalysisResult
|
:return: AnalysisResult
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -181,6 +182,10 @@ class DLManager(Process):
|
||||||
analysis_res.install_size = sum(fm.file_size for fm in manifest.file_manifest_list.elements
|
analysis_res.install_size = sum(fm.file_size for fm in manifest.file_manifest_list.elements
|
||||||
if fm.filename in mc.added)
|
if fm.filename in mc.added)
|
||||||
|
|
||||||
|
# todo properly handle delta manifests
|
||||||
|
if delta_manifest_used:
|
||||||
|
mc.removed = set()
|
||||||
|
|
||||||
if mc.removed:
|
if mc.removed:
|
||||||
analysis_res.removed = len(mc.removed)
|
analysis_res.removed = len(mc.removed)
|
||||||
self.log.debug(f'{analysis_res.removed} removed files')
|
self.log.debug(f'{analysis_res.removed} removed files')
|
||||||
|
|
Loading…
Reference in a new issue