cmd/uplink: Create dir before saving config file
Setup command of uplink has to create the configuration directory just before saving the configuration file for making it more robust than creating in the initial state of the process. When creating the directory at the beginning of the process leaves the possibility to delete such directory during the setup process and leads to a failure. Ticket https://storjlabs.atlassian.net/browse/V3-3545 Change-Id: I30db0175e23a597e9675d267b4d7e25d5d4c5119
This commit is contained in:
parent
6502454947
commit
80a6219c4b
@ -44,11 +44,6 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(setupDir, 0700)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if setupCfg.NonInteractive {
|
if setupCfg.NonInteractive {
|
||||||
return cmdSetupNonInteractive(cmd, setupDir)
|
return cmdSetupNonInteractive(cmd, setupDir)
|
||||||
}
|
}
|
||||||
@ -78,6 +73,12 @@ func cmdSetupNonInteractive(cmd *cobra.Command, setupDir string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = os.MkdirAll(setupDir, 0700)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return Error.Wrap(process.SaveConfig(cmd, filepath.Join(setupDir, process.DefaultCfgFilename),
|
return Error.Wrap(process.SaveConfig(cmd, filepath.Join(setupDir, process.DefaultCfgFilename),
|
||||||
process.SaveConfigWithOverride("access", accessData),
|
process.SaveConfigWithOverride("access", accessData),
|
||||||
process.SaveConfigRemovingDeprecated()))
|
process.SaveConfigRemovingDeprecated()))
|
||||||
@ -179,6 +180,11 @@ func cmdSetupInteractive(cmd *cobra.Command, setupDir string) error {
|
|||||||
saveCfgOpts = append(saveCfgOpts, process.SaveConfigWithOverride("access", accessName))
|
saveCfgOpts = append(saveCfgOpts, process.SaveConfigWithOverride("access", accessName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = os.MkdirAll(setupDir, 0700)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
configPath := filepath.Join(setupDir, process.DefaultCfgFilename)
|
configPath := filepath.Join(setupDir, process.DefaultCfgFilename)
|
||||||
err = process.SaveConfig(cmd, configPath, saveCfgOpts...)
|
err = process.SaveConfig(cmd, configPath, saveCfgOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user