Skip to content

fix(config): refuse to link a second folder under an existing site name - #159

Open
dhruv1220 wants to merge 1 commit into
flock-php:mainfrom
dhruv1220:fix/link-same-name-overwrite
Open

dhruv1220 wants to merge 1 commit into
flock-php:mainfrom
dhruv1220:fix/link-same-name-overwrite

Conversation

@dhruv1220

Copy link
Copy Markdown

Fixes #136.

Adding two sites whose folders share a name (e.g. two projects each with a platform folder) silently overwrote the first: the folder name becomes the site name, and Config.Upsert replaced the stored site by name, so only the second folder was ever served. The first site's path was lost with no warning.

Change (in internal/config/config.go):

  • Upsert now refuses when a linked site with the same name already points at a different folder, with an error naming the existing path and the remedy: unlink it first if the project moved, or link the folder under a different name (flock link <name>). The guard compares paths after symlink resolution, so the same folder spelled two ways still re-links.
  • Deliberately still allowed: re-linking the same folder with new settings, and linking over a parked directory with the same name (that is the promotion to a linked site; the parked folder stays parked and reappears if the link is removed).

Because the guard lives in Upsert, it covers every way a site is added: flock link, the GUI's add-site form (POST /v1/sites, which already surfaces Upsert errors as a 400), and the MCP site tools.

Tests:

  • New TestUpsertRefusesSameNameForAnotherPath in internal/config/config_test.go: same folder re-links fine; a second folder under the same name fails with an error naming the first path, and the stored site is untouched. The test fails on the old code and passes with the fix. The first version of this guard also covered parked-discovered names, which broke the existing TestAllSitesMergesParkedAndLinkedSites promotion case — the guard now only fires for stored linked sites.
  • go test ./internal/config/ ./internal/cli/ ./internal/api/ ./internal/mcpserver/ all green; gofmt and go vet clean.

@github-actions github-actions Bot added this to the v1.x milestone Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

You cannot add more than one site that has the same folder name

1 participant