mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[core/utils] Improve minimum disk space calculation when updating
This commit is contained in:
parent
0e6b63d1a2
commit
bb3d6f9348
|
@ -21,7 +21,7 @@ from legendary.api.egs import EPCAPI
|
|||
from legendary.downloader.manager import DLManager
|
||||
from legendary.lfs.egl import EPCLFS
|
||||
from legendary.lfs.lgndry import LGDLFS
|
||||
from legendary.utils.lfs import clean_filename, delete_folder, delete_filelist
|
||||
from legendary.utils.lfs import clean_filename, delete_folder, delete_filelist, get_dir_size
|
||||
from legendary.models.downloading import AnalysisResult, ConditionCheckResult
|
||||
from legendary.models.egl import EGLManifest
|
||||
from legendary.models.exceptions import *
|
||||
|
@ -888,7 +888,9 @@ class LegendaryCore:
|
|||
# check if enough disk space is free (dl size is the approximate amount the installation will grow)
|
||||
min_disk_space = analysis.install_size
|
||||
if updating:
|
||||
min_disk_space += analysis.biggest_file_size
|
||||
current_size = get_dir_size(install.install_path)
|
||||
delta = max(0, analysis.install_size - current_size)
|
||||
min_disk_space = delta + analysis.biggest_file_size
|
||||
|
||||
# todo when resuming, only check remaining files
|
||||
_, _, free = shutil.disk_usage(os.path.split(install.install_path)[0])
|
||||
|
|
|
@ -5,6 +5,7 @@ import shutil
|
|||
import hashlib
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Iterator
|
||||
|
||||
from legendary.models.game import VerifyResult
|
||||
|
@ -116,3 +117,7 @@ def validate_files(base_path: str, filelist: List[tuple], hash_type='sha1') -> I
|
|||
|
||||
def clean_filename(filename):
|
||||
return ''.join(i for i in filename if i not in '<>:"/\\|?*')
|
||||
|
||||
|
||||
def get_dir_size(path):
|
||||
return sum(f.stat().st_size for f in Path(path).glob('**/*') if f.is_file())
|
||||
|
|
Loading…
Reference in a new issue