Skip to content

Commit 33247c9

Browse files
committed
setup: ensure we check the dir before setting landlock
Fixes: #335 Signed-off-by: Morten Linderud <[email protected]>
1 parent 80c451c commit 33247c9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cmd/sbctl/setup.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ func MigrateSetup(state *config.State) error {
155155
newConf := config.DefaultConfig()
156156
p := path.Dir(newConf.Keydir)
157157

158+
// abort early if it exists
159+
if ok, _ := afero.DirExists(state.Fs, p); ok {
160+
logging.Print("%s already exists!\n", p)
161+
return nil
162+
}
163+
158164
if err := state.Fs.MkdirAll(p, os.ModePerm); err != nil {
159165
return err
160166
}
@@ -176,11 +182,6 @@ func MigrateSetup(state *config.State) error {
176182
return nil
177183
}
178184

179-
if ok, _ := afero.DirExists(state.Fs, p); ok {
180-
logging.Print("%s already exists!\n", p)
181-
return nil
182-
}
183-
184185
logging.Print("Moving files...")
185186
if err := sbctl.CopyDirectory(state.Fs, sbctl.DatabasePath, p); err != nil {
186187
logging.NotOk("")

0 commit comments

Comments
 (0)