Skip to content

Refuse a new VM whose name differs from another only in case - #122

Merged
A21-devs merged 1 commit into
mainfrom
fix/new-vm-case-clash
Dec 1, 2026
Merged

A21-devs merged 1 commit into
mainfrom
fix/new-vm-case-clash

Conversation

@A21-devs

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

Copy link
Copy Markdown
Owner

Closes #111

save without a previousName (a new VM from the wizard, or a clone) only checked that the name was valid. With a VM called Kali already there, saving a new kali wrote vms/kali.json, which on Windows is Kali.json, and replaced the first VM's settings and disk path without a word.

Now saveConfig refuses it with A VM called "kali" already exists, same as a rename onto a taken name. It compares against the files in vms/ ignoring case, so it catches exactly the file that would be overwritten. The mock backend refuses it too.

The wizard and clone dialog already check this, so nothing changes in the UI. This is the backend guarding itself.

Testing

  • npm run typecheck, npm test (140 passed), npm run build, npm run test:qemu (157 passed)
  • New test in tests/store.test.ts: a new kali and a second new Kali are both refused, the first VM's config is untouched, and saving the VM under its own name still works.

save without a previousName only validated the name. On Windows kali.json
is the existing Kali.json, so the new VM silently replaced the other
one's settings and disk path. The wizard and clone dialog already check
this, now the backend does too, like rename does. The mock backend
refuses it the same way.
@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.

Small and correct. The check only runs when there's no previousName, so normal saves and the Grow disk save (which passes the VM's own name) aren't affected, and clone goes through the same path, so it gets the guard too. Comparing directory entries instead of listConfigs names is the right call: it matches the file that would really be overwritten, even if a broken config can't be parsed.

Comment thread src/main/store.ts
/** a config file for this name is there already, ignoring case like Windows does */
function taken(paths: DataPaths, name: string): boolean {
const file = `${name}.json`.toLowerCase()
return existsSync(paths.vms) && readdirSync(paths.vms).some((f) => f.toLowerCase() === file)

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.

Nit: this also matches a leftover x.json that listConfigs skips because it doesn't parse, so the user gets "already exists" for a VM the library doesn't show. That's still better than overwriting it, and the message is enough to go and look in the vms folder. No change needed.

@A21-devs
A21-devs merged commit 2156738 into main Dec 1, 2026
1 check passed
@A21-devs
A21-devs deleted the fix/new-vm-case-clash branch December 1, 2026 15:26
@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.

Saving a new VM can overwrite one whose name differs only in case

1 participant