diff options
| author | chrislu <chris.lu@gmail.com> | 2022-01-21 00:26:49 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-01-21 00:26:49 -0800 |
| commit | f10349191228cb945cabfe049b601ab3e251b55c (patch) | |
| tree | 7cfc977da8e40f313691ad7caaaaae11918870ab | |
| parent | 6c7135d77ead544dab1c99373ba6cc96af63f323 (diff) | |
| download | seaweedfs-f10349191228cb945cabfe049b601ab3e251b55c.tar.xz seaweedfs-f10349191228cb945cabfe049b601ab3e251b55c.zip | |
s3: list bucket size from weed shell
| -rw-r--r-- | weed/shell/command_s3_bucket_list.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/weed/shell/command_s3_bucket_list.go b/weed/shell/command_s3_bucket_list.go index a344a79a4..540365af5 100644 --- a/weed/shell/command_s3_bucket_list.go +++ b/weed/shell/command_s3_bucket_list.go @@ -34,6 +34,14 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i return nil } + // collect collection information + topologyInfo, _, err := collectTopologyInfo(commandEnv) + if err != nil { + return err + } + collectionInfos := make(map[string]*CollectionInfo) + collectCollectionInfo(topologyInfo, collectionInfos) + _, parseErr := commandEnv.parseUrl(findInputDirectory(bucketCommand.Args())) if parseErr != nil { return parseErr @@ -49,11 +57,13 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i if !entry.IsDirectory { return nil } - if entry.Attributes.Replication == "" || entry.Attributes.Replication == "000" { - fmt.Fprintf(writer, " %s\n", entry.Name) - } else { - fmt.Fprintf(writer, " %s\t\t\treplication: %s\n", entry.Name, entry.Attributes.Replication) + collection := entry.Name + var collectionSize, fileCount uint64 + if collectionInfo, found := collectionInfos[collection]; found { + collectionSize = collectionInfo.Size + fileCount = collectionInfo.FileCount - collectionInfo.DeleteCount } + fmt.Fprintf(writer, " %s\tsize:%d bytes\tfile:%d\treplication: %s\n", entry.Name, collectionSize, fileCount, entry.Attributes.Replication) return nil }, "", false, math.MaxUint32) if err != nil { |
