Skip to content

Commit

Permalink
fix: clean up missing project if it's gone, fixes ddev#5322
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Mar 28, 2024
1 parent 18e53dc commit 3113e8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func NewApp(appRoot string, includeOverrides bool) (*DdevApp, error) {
return nil, fmt.Errorf("ddev config is not useful in your home directory (%s)", homeDir)
}

if !fileutil.FileExists(app.AppRoot) {
return app, fmt.Errorf("project root %s does not exist", app.AppRoot)
if _, err := os.Stat(app.AppRoot); err != nil {
return app, err
}

app.ConfigPath = app.GetConfigPath("config.yaml")
Expand Down
10 changes: 9 additions & 1 deletion pkg/ddevapp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,15 @@ func GetProjects(activeOnly bool) ([]*DdevApp, error) {

app, err := NewApp(info.AppRoot, true)
if err != nil {
util.Warning("Unable to create project at project root '%s': %v", info.AppRoot, err)
if os.IsNotExist(err) {
util.Warning("The project '%s' no longer exists in the filesystem, removing it from registry", info.AppRoot)
err = globalconfig.RemoveProjectInfo(name)
if err != nil {
util.Warning("unable to RemoveProjectInfo(%s): %v", name, err)
}
} else {
util.Warning("Something went wrong with %s: %v", info.AppRoot, err)
}
continue
}

Expand Down

0 comments on commit 3113e8a

Please sign in to comment.