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

@@ -251,6 +251,14 @@ def install(layout, lock, progress=None, cancel=None, log=print, version='dev'):
and (layout.pkgs / p['filename']).stat().st_size == p['csize'])]
total = sum(p['csize'] for p in need)
log(f'toolchain: {len(pkgs)} packages, {len(need)} to download ({total / 1e6:.0f} MB)')
# Room for the downloads and for the unpacked tools beside the ones in use (msys64.new), asked before the first
# download: a disk that fills while a package unpacks otherwise ends the step with an error that names no cause.
# A package's installed size is in the lock; of a CLANG64 package only a few files are unpacked (_wanted), for
# which its download size stands in.
unpacked = sum(p['csize'] if p.get('env') else p.get('isize', 0) for p in pkgs)
full = net.space_problem(layout.toolchain, total + unpacked, 'the build tools')
if full:
raise ToolchainError(full)
done_before = 0
for p in need:
dest = layout.pkgs / p['filename']
@@ -264,6 +272,8 @@ def install(layout, lock, progress=None, cancel=None, log=print, version='dev'):
version=version)
last_error = None
break
except net.NoSpace as e: # another server has the same file for the same full disk
raise ToolchainError(str(e)) from e
except net.DownloadError as e:
last_error = e
log(f'toolchain: {e}')