aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_fs_du.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-23 21:37:04 -0700
committerChris Lu <chris.lu@gmail.com>2020-03-23 21:37:04 -0700
commit38e73463f1c8c7d7dc226ea41679407cb66101d4 (patch)
treece07a84681e51ca1023c33c0bc3898132bde4295 /weed/shell/command_fs_du.go
parentb51fa81f0e7cd7ab21f3683f356b0380f9dce75b (diff)
downloadseaweedfs-38e73463f1c8c7d7dc226ea41679407cb66101d4.tar.xz
seaweedfs-38e73463f1c8c7d7dc226ea41679407cb66101d4.zip
fix du block and byte couting
Diffstat (limited to 'weed/shell/command_fs_du.go')
-rw-r--r--weed/shell/command_fs_du.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/shell/command_fs_du.go b/weed/shell/command_fs_du.go
index f3d479614..dc5c3dec0 100644
--- a/weed/shell/command_fs_du.go
+++ b/weed/shell/command_fs_du.go
@@ -56,6 +56,9 @@ func (c *commandFsDu) Do(args []string, commandEnv *CommandEnv, writer io.Writer
func duTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dir, name string) (blockCount, byteCount uint64, err error) {
err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) {
+
+ var fileBlockCount, fileByteCount uint64
+
if entry.IsDirectory {
subDir := fmt.Sprintf("%s/%s", dir, entry.Name)
if dir == "/" {
@@ -67,12 +70,14 @@ func duTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dir
byteCount += numByte
}
} else {
+ fileBlockCount = uint64(len(entry.Chunks))
+ fileByteCount = filer2.TotalSize(entry.Chunks)
blockCount += uint64(len(entry.Chunks))
byteCount += filer2.TotalSize(entry.Chunks)
}
if name != "" && !entry.IsDirectory {
- fmt.Fprintf(writer, "block:%4d\tbyte:%10d\t%s/%s\n", blockCount, byteCount, dir, name)
+ fmt.Fprintf(writer, "block:%4d\tbyte:%10d\t%s/%s\n", fileBlockCount, fileByteCount, dir, entry.Name)
}
})
return