storageminer: Improve storage find cmd
This commit is contained in:
parent
c57c0e7f55
commit
c6f67911de
@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@ -168,7 +169,9 @@ var storageListCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type storedSector struct {
|
type storedSector struct {
|
||||||
|
id stores.ID
|
||||||
store stores.StorageInfo
|
store stores.StorageInfo
|
||||||
|
|
||||||
unsealed, sealed, cache bool
|
unsealed, sealed, cache bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +231,7 @@ var storageFindCmd = &cli.Command{
|
|||||||
sts, ok := byId[info.ID]
|
sts, ok := byId[info.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
sts = &storedSector{
|
sts = &storedSector{
|
||||||
|
id: info.ID,
|
||||||
store: info,
|
store: info,
|
||||||
}
|
}
|
||||||
byId[info.ID] = sts
|
byId[info.ID] = sts
|
||||||
@ -238,6 +242,7 @@ var storageFindCmd = &cli.Command{
|
|||||||
sts, ok := byId[info.ID]
|
sts, ok := byId[info.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
sts = &storedSector{
|
sts = &storedSector{
|
||||||
|
id: info.ID,
|
||||||
store: info,
|
store: info,
|
||||||
}
|
}
|
||||||
byId[info.ID] = sts
|
byId[info.ID] = sts
|
||||||
@ -248,6 +253,7 @@ var storageFindCmd = &cli.Command{
|
|||||||
sts, ok := byId[info.ID]
|
sts, ok := byId[info.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
sts = &storedSector{
|
sts = &storedSector{
|
||||||
|
id: info.ID,
|
||||||
store: info,
|
store: info,
|
||||||
}
|
}
|
||||||
byId[info.ID] = sts
|
byId[info.ID] = sts
|
||||||
@ -260,10 +266,29 @@ var storageFindCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, info := range byId {
|
var out []*storedSector
|
||||||
fmt.Printf("In %s (Unsealed: %t; Sealed: %t; Cache: %t)\n", id, info.unsealed, info.sealed, info.cache)
|
for _, sector := range byId {
|
||||||
|
out = append(out, sector)
|
||||||
|
}
|
||||||
|
sort.Slice(out, func(i, j int) bool {
|
||||||
|
return out[i].id < out[j].id
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, info := range out {
|
||||||
|
var types string
|
||||||
|
if info.unsealed {
|
||||||
|
types += "Unsealed, "
|
||||||
|
}
|
||||||
|
if info.sealed {
|
||||||
|
types += "Sealed, "
|
||||||
|
}
|
||||||
|
if info.cache {
|
||||||
|
types += "Cache, "
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("In %s (%s)\n", info.id, types[:len(types)-2])
|
||||||
fmt.Printf("\tSealing: %t; Storage: %t\n", info.store.CanSeal, info.store.CanSeal)
|
fmt.Printf("\tSealing: %t; Storage: %t\n", info.store.CanSeal, info.store.CanSeal)
|
||||||
if localPath, ok := local[id]; ok {
|
if localPath, ok := local[info.id]; ok {
|
||||||
fmt.Printf("\tLocal (%s)\n", localPath)
|
fmt.Printf("\tLocal (%s)\n", localPath)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("\tRemote\n")
|
fmt.Printf("\tRemote\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user