Skip to content

Commit

Permalink
Avoid conflict between binary location and workspace
Browse files Browse the repository at this point in the history
Don't try to create the workspace directory on top of the binary, if the
binary happens to be downloaded to the default workspace directory.
  • Loading branch information
Katrina Owen committed Jun 22, 2018
1 parent 29a26ee commit a607135
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"path"
"text/tabwriter"

Expand Down Expand Up @@ -35,7 +36,14 @@ You can also override certain default settings to suit your preferences.
return err
}
if usrCfg.Workspace == "" {
usrCfg.Workspace = path.Join(usrCfg.Home, path.Base(BinaryName))
dirName := path.Base(BinaryName)
defaultWorkspace := path.Join(usrCfg.Home, dirName)
_, err := os.Stat(defaultWorkspace)
// Sorry about the double negative.
if !os.IsNotExist(err) {
defaultWorkspace = fmt.Sprintf("%s-1", defaultWorkspace)
}
usrCfg.Workspace = defaultWorkspace
}

apiCfg := config.NewEmptyAPIConfig()
Expand Down

0 comments on commit a607135

Please sign in to comment.