mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[downloader/models] Calculate maximum disk space delta during installation
This commit is contained in:
parent
05aac59836
commit
202f07973a
|
@ -208,6 +208,8 @@ class DLManager(Process):
|
|||
fmlist = sorted(manifest.file_manifest_list.elements,
|
||||
key=lambda a: a.filename.lower())
|
||||
|
||||
# Create reference count for chunks and calculate additional/temporary disk size required for install
|
||||
current_tmp_size = 0
|
||||
for fm in fmlist:
|
||||
self.hash_map[fm.filename] = fm.sha_hash.hex()
|
||||
|
||||
|
@ -219,6 +221,20 @@ class DLManager(Process):
|
|||
for cp in fm.chunk_parts:
|
||||
references[cp.guid_num] += 1
|
||||
|
||||
if fm.filename in mc.added:
|
||||
# if the file was added, it just adds to the delta
|
||||
current_tmp_size += fm.file_size
|
||||
analysis_res.disk_space_delta = max(current_tmp_size, analysis_res.disk_space_delta)
|
||||
elif fm.filename in mc.changed:
|
||||
# if the file was changed, we need temporary space equal to the full size,
|
||||
# but then subtract the size of the old file as it's deleted on write completion.
|
||||
current_tmp_size += fm.file_size
|
||||
analysis_res.disk_space_delta = max(current_tmp_size, analysis_res.disk_space_delta)
|
||||
current_tmp_size -= old_manifest.file_manifest_list.get_file_by_path(fm.filename).file_size
|
||||
|
||||
# clamp to 0
|
||||
self.log.debug(f'Disk space delta: {analysis_res.disk_space_delta/1024/1024:.02f} MiB')
|
||||
|
||||
if processing_optimization:
|
||||
s_time = time.time()
|
||||
# reorder the file manifest list to group files that share many chunks
|
||||
|
|
|
@ -127,6 +127,7 @@ class AnalysisResult:
|
|||
dl_size: int = 0
|
||||
uncompressed_dl_size: int = 0
|
||||
install_size: int = 0
|
||||
disk_space_delta: int = 0
|
||||
reuse_size: int = 0
|
||||
biggest_file_size: int = 0
|
||||
unchanged_size: int = 0
|
||||
|
|
Loading…
Reference in a new issue