Repository navigation
Refuse a new VM whose name differs from another only in case - #122
Merged
Merged
Conversation
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
commented
Dec 1, 2026
A21-devs
left a comment
Owner
Author
There was a problem hiding this comment.
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.
| /** 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) |
Owner
Author
There was a problem hiding this comment.
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #111
savewithout apreviousName(a new VM from the wizard, or a clone) only checked that the name was valid. With a VM calledKalialready there, saving a newkaliwrotevms/kali.json, which on Windows isKali.json, and replaced the first VM's settings and disk path without a word.Now
saveConfigrefuses it withA VM called "kali" already exists, same as a rename onto a taken name. It compares against the files invms/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)tests/store.test.ts: a newkaliand a second newKaliare both refused, the first VM's config is untouched, and saving the VM under its own name still works.