mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3: list bucket size from weed shell
This commit is contained in:
parent
6c7135d77e
commit
f103491912
|
@ -34,6 +34,14 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i
|
||||||
return nil
|
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()))
|
_, parseErr := commandEnv.parseUrl(findInputDirectory(bucketCommand.Args()))
|
||||||
if parseErr != nil {
|
if parseErr != nil {
|
||||||
return parseErr
|
return parseErr
|
||||||
|
@ -49,11 +57,13 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i
|
||||||
if !entry.IsDirectory {
|
if !entry.IsDirectory {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if entry.Attributes.Replication == "" || entry.Attributes.Replication == "000" {
|
collection := entry.Name
|
||||||
fmt.Fprintf(writer, " %s\n", entry.Name)
|
var collectionSize, fileCount uint64
|
||||||
} else {
|
if collectionInfo, found := collectionInfos[collection]; found {
|
||||||
fmt.Fprintf(writer, " %s\t\t\treplication: %s\n", entry.Name, entry.Attributes.Replication)
|
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
|
return nil
|
||||||
}, "", false, math.MaxUint32)
|
}, "", false, math.MaxUint32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue