Ask the disk for room before a download or an unpack starts.

A disk that filled in the middle ended a download after four tries with an error that named no cause, and an unpack
with half a folder. The rest of a download, the build tools with their unpacked size, an update's archive and a
mod's zip are now measured against the free space first, and the refusal says how much is needed and how much is
free; a disk that fills during a download is named as full at once.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-12 22:19:28 -05:00
parent fe041188f5
commit d0e6cd695e
6 changed files with 156 additions and 4 deletions

View File

@@ -32,7 +32,7 @@ import time
import zipfile
from pathlib import Path
from . import gameini
from . import gameini, net
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
import mod_files # noqa: E402
@@ -409,6 +409,9 @@ def unpack(archive, dest):
try:
with zipfile.ZipFile(archive) as z:
_safe_members(z.namelist())
full = net.space_problem(dest, sum(i.file_size for i in z.infolist()), 'its files')
if full: # told before a file is written, not as an error halfway through
raise ModError(full)
z.extractall(dest)
except (zipfile.BadZipFile, NotImplementedError, RuntimeError) as e:
raise ModError(f'it is not a zip file the launcher can read ({e})')