[downloader/models] Calculate maximum disk space delta during installation

This commit is contained in:
derrod 2022-01-02 13:06:59 +01:00
parent 05aac59836
commit 202f07973a
2 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -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