From f9be73c73ecb3e1d02d7b0d82e659ef8a235c6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 1 May 2020 20:43:39 +0200 Subject: [PATCH] storageminer: Fix 'storage list' with disconnected storage --- cmd/lotus-storage-miner/storage.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/lotus-storage-miner/storage.go b/cmd/lotus-storage-miner/storage.go index 875c5e9a6..47a1a7729 100644 --- a/cmd/lotus-storage-miner/storage.go +++ b/cmd/lotus-storage-miner/storage.go @@ -142,22 +142,21 @@ var storageListCmd = &cli.Command{ return err } - sorted := make([]struct { + type fsInfo struct { stores.ID sectors []stores.Decl stat stores.FsStat - }, 0, len(st)) + } + + sorted := make([]fsInfo, 0, len(st)) for id, decls := range st { st, err := nodeApi.StorageStat(ctx, id) if err != nil { - return err + sorted = append(sorted, fsInfo{ID: id, sectors: decls}) + continue } - sorted = append(sorted, struct { - stores.ID - sectors []stores.Decl - stat stores.FsStat - }{id, decls, st}) + sorted = append(sorted, fsInfo{id, decls, st}) } sort.Slice(sorted, func(i, j int) bool { @@ -178,10 +177,13 @@ var storageListCmd = &cli.Command{ } } + fmt.Printf("%s:\n", s.ID) + pingStart := time.Now() st, err := nodeApi.StorageStat(ctx, s.ID) if err != nil { - return err + fmt.Printf("\t%s: %s:\n", color.RedString("Error"), err) + continue } ping := time.Now().Sub(pingStart) @@ -199,7 +201,6 @@ var storageListCmd = &cli.Command{ set := (st.Capacity-st.Available)*barCols/st.Capacity bar := strings.Repeat("|", int(set)) + strings.Repeat(" ", int(barCols-set)) - fmt.Printf("%s:\n", s.ID) fmt.Printf("\t[%s] %s/%s %s\n", color.New(percCol).Sprint(bar), types.SizeStr(types.NewInt(st.Capacity-st.Available)), types.SizeStr(types.NewInt(st.Capacity)),