Return error form Repo.Exists
This commit is contained in:
parent
4f1946d5a2
commit
4c8b028887
@ -21,7 +21,11 @@ var initCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if r.Exists() {
|
||||
ok, err := r.Exists()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok {
|
||||
return xerrors.Errorf("repo at '%s' is already initialized", cctx.String(FlagStorageRepo))
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,11 @@ var runCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if !r.Exists() {
|
||||
ok, err := r.Exists()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !ok {
|
||||
return xerrors.Errorf("repo at '%s' is not initialized, run 'lotus-storage-miner init' to set it up", cctx.String(FlagStorageRepo))
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,13 @@ func NewFS(path string) (*FsRepo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (fsr *FsRepo) Exists() bool {
|
||||
func (fsr *FsRepo) Exists() (bool, error) {
|
||||
_, err := os.Stat(fsr.path)
|
||||
return err == nil
|
||||
notexist := os.IsNotExist(err)
|
||||
if notexist {
|
||||
err = nil
|
||||
}
|
||||
return !notexist, err
|
||||
}
|
||||
|
||||
func (fsr *FsRepo) Init() error {
|
||||
|
Loading…
Reference in New Issue
Block a user