Skip to content

Commit

Permalink
setup: ensure we check the dir before setting landlock
Browse files Browse the repository at this point in the history
Fixes: #335

Signed-off-by: Morten Linderud <[email protected]>
  • Loading branch information
Foxboron committed Jul 31, 2024
1 parent 80c451c commit 33247c9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/sbctl/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func MigrateSetup(state *config.State) error {
newConf := config.DefaultConfig()
p := path.Dir(newConf.Keydir)

// abort early if it exists
if ok, _ := afero.DirExists(state.Fs, p); ok {
logging.Print("%s already exists!\n", p)
return nil
}

if err := state.Fs.MkdirAll(p, os.ModePerm); err != nil {
return err
}
Expand All @@ -176,11 +182,6 @@ func MigrateSetup(state *config.State) error {
return nil
}

if ok, _ := afero.DirExists(state.Fs, p); ok {
logging.Print("%s already exists!\n", p)
return nil
}

logging.Print("Moving files...")
if err := sbctl.CopyDirectory(state.Fs, sbctl.DatabasePath, p); err != nil {
logging.NotOk("")
Expand Down

0 comments on commit 33247c9

Please sign in to comment.