Skip to content

Clean up cut-off compacts next to disks outside the data folder - #163

Merged
A21-devs merged 3 commits into
mainfrom
fix/compact-leftovers-anywhere
Dec 5, 2026
Merged

A21-devs merged 3 commits into
mainfrom
fix/compact-leftovers-anywhere

Conversation

@A21-devs

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

Copy link
Copy Markdown
Owner

Closes #157

#151 deletes a cut-off clone or compact at startup, but only in the disks folder. A compact writes <diskPath>.compact.tmp next to the disk, and a VM's disk can be anywhere, so a VM pointed at an existing qcow2 elsewhere kept its leftover (as big as the used part of the disk) until its next compact.

  • New removeUnfinishedCompacts(configs) in src/main/disks.ts: for each VM it checks the one path a compact of that VM would have written and deletes it if it is there. It never lists those folders, so nothing else in them is looked at.
  • It runs at startup right after the disks folder scan, before anything can start a VM. A compact only runs with its VM off, and the single instance lock keeps a second app from compacting, so the file can't be in use by us.
  • In the disks folder it also picks up a disk whose name doesn't end in .qcow2, which the folder scan skips on purpose.
  • The Still working question said an unfinished clone or compact "stays" behind. Both are removed at the next start now, so the text says that.

Testing

  • 3 new tests in tests/clones.test.ts: a leftover next to a disk outside the disks folder (with another program's file and a compact file no VM points at left alone), a non-.qcow2 disk, and no leftover at all
  • npm run typecheck, npm test (195 pass), npm run test:qemu (212 pass), npm run build
  • Hidden Electron smoke run with a temp data folder holding one VM whose disk is in a second temp folder next to a .compact.tmp: the log says removed unfinished disk files: ...Elsewhere.qcow2.compact.tmp, the disk is still there, SMOKE OK

The startup cleanup from #151 only looked in the disks folder, but a
compact writes its temporary file next to the disk, and a VM's config can
point at a disk anywhere. For each VM it now also removes
<diskPath>.compact.tmp if it is there. It checks only that exact path, so
it never scans the user's other folders. In the disks folder it also
catches a disk that isn't named .qcow2, which the folder scan skips.
…ing leaves

The Still working question said an unfinished clone or compact stays
behind. Both are deleted at the next start now, so it says that.
@A21-devs A21-devs added enhancement New feature or request backend labels Dec 5, 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.

Read the diff and the startup order in registerIpc: the cleanup runs before autostart or any IPC can start a VM, and it only ever touches <diskPath>.compact.tmp for configs that exist. One wording problem below.

Comment thread src/main/quitFlow.ts Outdated
removing: 'the profile may not be deleted',
cloning: 'the unfinished copy of the disk stays in the disks folder',
compacting: 'the unfinished compacted copy stays next to the disk until the next compact',
cloning: 'the unfinished copy of the disk is deleted the next time the app starts',

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.

This is only true for a full clone. A linked clone has no .vmm-clone file to delete: it renames the source disk to the base and creates two overlays, and cut off in between it leaves the source VM without a disk (#156). Saying the copy "is deleted the next time the app starts" tells the user quitting is harmless when for a linked clone it isn't. It should at least say full copy, until #156 lands.

@A21-devs

A21-devs commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

Right, the new text overpromised for linked clones. 4332af5 says an unfinished full copy is deleted at the next start and that a linked clone cut off while it sets up can leave the VM without its disk. I'll come back to this text with #156. Reran npm run typecheck and npm test (195 pass).

@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 the follow-up: the cloning line now only promises the cleanup for a full copy and names the linked clone risk. The message box joins the detail parts with ", and ", so the longer sentence still reads fine with a second kind of work. Nothing else open here.

Only a full clone writes a separate file the startup cleanup removes. A
linked clone stopped between its rename and its overlays leaves the
source VM without a disk (#156), so say so.
@A21-devs
A21-devs merged commit 277f1c3 into main Dec 5, 2026
1 check passed
@A21-devs
A21-devs deleted the fix/compact-leftovers-anywhere branch December 5, 2026 20:10
@A21-devs A21-devs mentioned this pull request Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unfinished compact files outside the disks folder are never cleaned up

1 participant