From e7686d9a96dabd87b36b00e06e24117fca79708c Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Fri, 6 Sep 2024 17:57:11 +0800 Subject: [PATCH] update: file size humanize show --- lib/file/file_windows.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/file/file_windows.go b/lib/file/file_windows.go index 81ba749a..fbcf9b3c 100644 --- a/lib/file/file_windows.go +++ b/lib/file/file_windows.go @@ -6,9 +6,6 @@ package file import ( "os" "path/filepath" - "strings" - - "github.com/dustin/go-humanize" ) type FileInfo struct { @@ -17,7 +14,7 @@ type FileInfo struct { LinkCount int64 `json:"linkCount"` // 硬链接数目 Owner string `json:"owner"` // 所属用户 Group string `json:"group"` // 所属组 - Size string `json:"size"` // 文件的大小 + Size int64 `json:"size"` // 文件的大小 ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒 FileName string `json:"fileName"` // 文件的名称 } @@ -43,14 +40,13 @@ func GetFileInfo(dir, suffix string) ([]FileInfo, error) { // check if match suffix if (suffix != "" && filepath.Ext(path) == suffix) || suffix == "" { - humanReadableSize := humanize.Bytes(uint64(info.Size())) fileInfo := FileInfo{ FileType: fileType, FileMode: info.Mode().String(), LinkCount: 0, Owner: "-", Group: "-", - Size: strings.ToUpper(humanReadableSize), + Size: info.Size(), ModifiedTime: info.ModTime().Unix(), FileName: info.Name(), }