repo: check for config in exists

This commit is contained in:
Łukasz Magiera 2019-07-24 13:20:00 +02:00
parent 81d7c30fac
commit 4fa9e45eb7
2 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,9 @@ var runCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
v, err := nodeApi.Version(ctx)
if err != nil {
return err
}
r, err := repo.NewFS(cctx.String(FlagStorageRepo))
if err != nil {

View File

@ -59,7 +59,7 @@ func NewFS(path string) (*FsRepo, error) {
}
func (fsr *FsRepo) Exists() (bool, error) {
_, err := os.Stat(fsr.path)
_, err := os.Stat(filepath.Join(fsr.path, fsConfig))
notexist := os.IsNotExist(err)
if notexist {
err = nil
@ -79,6 +79,14 @@ func (fsr *FsRepo) Init() error {
if err != nil {
return err
}
c, err := os.Create(filepath.Join(fsr.path, fsConfig))
if err != nil {
return err
}
if err := c.Close(); err != nil {
return err
}
return fsr.initKeystore()
}