Repository navigation
sdk/local: nebi owns existing project directories (#683) - #694
Open
gsegovia2018 wants to merge 1 commit into
Open
gsegovia2018 wants to merge 1 commit into
gsegovia2018 wants to merge 1 commit into
Conversation
Member
IMO full deletion is fine for now. Ownership means that the directory and everything in it belongs to nebi and in turn can be deleted if the user instructs nebi to do so. We can build more complex logic later. |
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 #683.
Summary
Implements the decision in #683: a project may use an existing directory, nebi owns it once the project is created, and deleting the project with its files removes that directory with everything in it, the same as a directory nebi created.
CreateProjectno longer distinguishes nebi-created and existing directories.DeleteProjectwithDeleteFilesno longer refuses existing directories.Project.ManagedDir,ProjectDetail.ManagedDir(managed_dirin JSON) andErrFilesNotManaged.Protected directories (beyond the decision)
Owning any existing directory means delete-with-files can now remove far more than before, so this adds
ErrProtectedPath.CreateProjectrefuses, andDeleteProjectrefuses to delete the files of, a directory that is:Options.ProjectsDir, default~/nebi-projects) or a directory that contains it.The checks compare directories on disk (
os.SameFile), so symlinks and case-insensitive filesystems are covered. The delete-time check also guards rows created before this change. Projects inside the projects directory, such as~/nebi-projects/foo, are unaffected.The projects directory is guarded because a project there would contain every default project directory, including directories kept by delete-without-files, and would already block every default create with
ErrPathTaken.Notes
managed_dircolumn stays in existing client databases.Migrateonly adds tables and columns, and GORM ignores the unused column.internal/client/api#663 needs a mapping forErrProtectedPath;ErrFilesNotManagedis gone.internal/client/sdk/local#660, Version CRUD ininternal/client/sdk/local#661, Client API for project CRUD ininternal/client/api#663 and CLI commands for project CRUD ininternal/client/cli#664 still describe managed directories and should be updated to match.nebi-client.db,owner.lock,owner.json) is not protected yet. No production caller ofDeleteProjectexists until Client API foundation and composition roots (internal/client/api,web,desktop) #680 wireslocal.New; I'd handle it in a follow-up.Deleting the whole directory
Delete-with-files removes the whole directory, including files nebi never wrote. pmeier confirmed this is the intended behavior for now (comment); finer-grained deletion can come later.
Testing
go test -race ./internal/client/...,go vet, gofmt and golangci-lint are clean. New tests cover create and delete refusing the root, home, the projects directory, their parents and a symlink to home, plus deleting an existing directory with its files.AI disclosure
claude-opus-5-5) via Claude Code.internal/client/sdk/localand this PR description, reviewed and approved by the author before pushing.ManagedDirremoved), run a multi-reviewer critical pass, then explain the changes before opening a draft PR.