mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 12:29:57 -04:00
Remove a cut RomFS image before measuring the free space.
A RomFS step that was cut short (Cancel, a full disk, a power cut) leaves romfs.bin.part, up to 26 GB. The next run writes the image anew, but make_game.py's step_romfs and the launcher's Begin Installation measured the free space first, with that file counted as used: on a nearly full disk the retry was refused although it needs no more room than the first try. Both remove the file before they measure, and the first-run screen counts its size as free. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,25 @@ def note_exit_in_log(game_dir, text):
|
||||
pass
|
||||
|
||||
|
||||
def partial_image_gb(game_dir):
|
||||
"""The size of what an install that was cut short left of the RomFS image (romfs/romfs.bin.part, up to 26 GB).
|
||||
The next install writes the image anew (tools/make_game.py step_romfs), so that space is the install's to use:
|
||||
the first-run screen counts it as free."""
|
||||
try:
|
||||
return (Path(game_dir) / 'romfs' / 'romfs.bin.part').stat().st_size / 1e9
|
||||
except OSError:
|
||||
return 0.0
|
||||
|
||||
|
||||
def drop_partial_image(game_dir):
|
||||
"""Removes that file (partial_image_gb), so that it does not count against the free space an install asks
|
||||
for."""
|
||||
try:
|
||||
(Path(game_dir) / 'romfs' / 'romfs.bin.part').unlink(missing_ok=True)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def drive_of(path):
|
||||
return Path(path).anchor.rstrip('\\/') or str(Path(path).parent)
|
||||
|
||||
@@ -731,7 +750,7 @@ class App:
|
||||
'found in Downloads, Desktop or Documents.',)
|
||||
gd = self.game_dir()
|
||||
need = 30
|
||||
free = free_gb(gd)
|
||||
free = free_gb(gd) + partial_image_gb(gd) # Begin Installation removes the partial image (begin_install)
|
||||
folder_desc = (f'The game is built into this folder. {free:.0f} GB free on {drive_of(gd)}; the game needs '
|
||||
f'about {need} GB. Select this row to choose another folder.',)
|
||||
ready = bool(dump)
|
||||
@@ -828,6 +847,7 @@ class App:
|
||||
self.choose_dump()
|
||||
return
|
||||
gd = self.game_dir()
|
||||
drop_partial_image(gd) # before the free space is measured
|
||||
if free_gb(gd) < 31 and not (Path(gd) / 'romfs' / 'romfs.bin').is_file():
|
||||
self.message = f'{drive_of(gd)} has {free_gb(gd):.0f} GB free; the game needs about 30 GB.'
|
||||
self.render()
|
||||
|
||||
Reference in New Issue
Block a user