cli: added 'block list --deleted-only' option
blockListLong = blockListCommand.Flag("long", "Long output").Short('l').Bool()
blockListPrefix = blockListCommand.Flag("prefix", "Prefix").String()
blockListIncludeDeleted = blockListCommand.Flag("deleted", "Include deleted blocks").Bool()
+ blockListDeletedOnly = blockListCommand.Flag("deleted-only", "Only show deleted blocks").Bool()
blockListSort = blockListCommand.Flag("sort", "Sort order").Default("name").Enum("name", "size", "time", "none", "pack")
blockListReverse = blockListCommand.Flag("reverse", "Reverse sort").Short('r').Bool()
blockListSummary = blockListCommand.Flag("summary", "Summarize the list").Short('s').Bool()
)
func runListBlocksAction(ctx context.Context, rep *repo.Repository) error {
- blocks, err := rep.Blocks.ListBlockInfos(*blockListPrefix, *blockListIncludeDeleted)
+ blocks, err := rep.Blocks.ListBlockInfos(*blockListPrefix, *blockListIncludeDeleted || *blockListDeletedOnly)
if err != nil {
return err
}
@@ -31,6 +32,9 @@ func runListBlocksAction(ctx context.Context, rep *repo.Repository) error {
var totalSize int64
uniquePacks := map[string]bool{}
for _, b := range blocks {
+ if *blockListDeletedOnly && !b.Deleted {
+ continue
+ }
totalSize += int64(b.Length)
count++
if b.PackFile != "" {
