cmd/storagenode: Change order load id in setup

Change the order of when the storage node setup node loads the identity
for avoiding to write anything in the disk in the case that there is an
error loading the identity.

This bug was reported by @onionjake Github username's and the specific
changes to make.

Closes #4387 #4396

Change-Id: I360fff3c23b160c9e055203d3526d749edfd9129
This commit is contained in:
Ivan Fraixedes 2022-02-03 16:00:29 +01:00
parent 11a35520c3
commit 7f1dc74e37
No known key found for this signature in database
GPG Key ID: 042B474597F96DB7

View File

@ -267,6 +267,11 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return fmt.Errorf("storagenode configuration already exists (%v)", setupDir)
}
identity, err := setupCfg.Identity.Load()
if err != nil {
return err
}
err = os.MkdirAll(setupDir, 0700)
if err != nil {
return err
@ -301,11 +306,6 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err
}
identity, err := setupCfg.Identity.Load()
if err != nil {
return err
}
if err := db.Pieces().CreateVerificationFile(ctx, identity.ID); err != nil {
return err
}