mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 19:29:57 -04:00
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:
@@ -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})')
|
||||
|
||||
Reference in New Issue
Block a user