Skip to content

Remove unfinished ISO copies when the app starts - #124

Merged
A21-devs merged 3 commits into
mainfrom
fix/iso-part-cleanup
Dec 1, 2026
Merged

A21-devs merged 3 commits into
mainfrom
fix/iso-part-cleanup

Conversation

@A21-devs

@A21-devs A21-devs commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Closes #54

Copying a dropped ISO into the ISOs folder writes <name>.iso.part and renames it at the end (#52). If the app is closed or crashes in the middle, the .part file stays. The app never lists it, so the only sign was GBs of disk space gone.

  • removePartFiles(isosDir) in isos.ts deletes every *.iso.part (any case) in the ISOs folder and returns the names. Files it can't delete are skipped and tried again on the next start. Other files, including a notes.part that isn't ours, are left alone.
  • registerIpc calls it once at startup, before the folder watcher starts. No copy can be running then, and the single instance lock means a second copy of the app can't be in the middle of one either. What it removed goes to the console.

Testing

  • npm run typecheck, npm test (142 passed), npm run build
  • New tests in tests/isos.test.ts: removes x (2).iso.part and BIG.ISO.PART, keeps kali.iso and notes.part, and copes with a missing folder.
  • Hidden smoke run (VMM_SMOKE=1) with a temp data folder holding test.iso.part and keep.iso: logged removed unfinished ISO copies: test.iso.part, printed SMOKE OK, keep.iso was still there.

A copy writes <name>.iso.part and renames it when done. If the app is
closed or crashes mid-copy the .part file stays, invisible in the app,
taking GBs. removePartFiles deletes *.iso.part in the ISOs folder and
skips anything it can't delete.
At startup no copy can be running, and the single instance lock keeps a
second copy of the app from starting one, so .part files there are
always leftovers.
@A21-devs A21-devs added bug Something isn't working backend labels Dec 1, 2026

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Startup is the right place, and the try/catch per file means a locked file or a folder called x.iso.part can't stop the app from starting. One real problem with what gets matched, inline.

Comment thread src/main/isos.ts
return names.filter((f) => {
if (!f.toLowerCase().endsWith('.iso.part')) return false
try {
rmSync(join(isosDir, f))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*.iso.part isn't only ours. Firefox downloads to <name>.iso.part next to the final file, and people do point downloads at the ISOs folder. Starting the app during a Firefox download of an ISO would delete the half-done download, and Firefox then fails it. Our copies should use a suffix nobody else uses (say .iso.vmm-copy), and this should only remove that one.

@A21-devs

A21-devs commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner Author

Good catch, fixed in 286e22d. Copies now write <name>.iso.vmm-copy (COPY_SUFFIX in isos.ts), and the startup cleanup (renamed to removeUnfinishedCopies) only deletes *.iso.vmm-copy. The test now puts a debian.iso.part next to ours and checks it survives.

Leftover .iso.part files from 0.2.0-0.5.0 copies aren't removed automatically, since we can't tell them from a Firefox download. I'll put that in the wiki's Where files live page.

Reran typecheck, npm test (142 passed), build, and the hidden smoke run with a.iso.vmm-copy and b.iso.part in the temp ISOs folder: only the first was removed.

Firefox downloads to <name>.iso.part, so deleting *.iso.part at startup
could kill a download in progress in the ISOs folder. Copies now write
<name>.iso.vmm-copy and only that suffix is cleaned up. Renamed
removePartFiles to removeUnfinishedCopies to match.

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked 286e22d against the earlier comment. copyInto and the cleanup both use COPY_SUFFIX now, so the two can't drift apart, and the match is on .iso.vmm-copy lowercased, so a Firefox .iso.part (or anything else) is left alone. The test covers exactly that case. listIsos still only lists names ending in .iso, so an in-progress copy stays hidden from the ISO picker as before. Resolved.

@A21-devs
A21-devs merged commit 201e14c into main Dec 1, 2026
1 check passed
@A21-devs
A21-devs deleted the fix/iso-part-cleanup branch December 1, 2026 15:32
@A21-devs A21-devs mentioned this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leftover .part file when the app quits during an ISO copy

1 participant