Allow deleting projects from the project picker with x/X.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
type Store interface {
|
||||
List() ([]Project, error)
|
||||
Ensure(id string) error
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
// DirStore discovers projects as subdirectories of dataDir/projects.
|
||||
@@ -63,3 +64,25 @@ func (s *DirStore) Ensure(id string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete removes the project directory and all of its files.
|
||||
func (s *DirStore) Delete(id string) error {
|
||||
if id == "" {
|
||||
return fmt.Errorf("project id is required")
|
||||
}
|
||||
dir := filepath.Join(s.projectsRoot(), id)
|
||||
st, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return fmt.Errorf("project %s: not found", id)
|
||||
}
|
||||
return fmt.Errorf("stat project %s: %w", id, err)
|
||||
}
|
||||
if !st.IsDir() {
|
||||
return fmt.Errorf("project %s: not a directory", id)
|
||||
}
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
return fmt.Errorf("delete project %s: %w", id, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user