fit: 文件显示大小值问题修复 (#5583)

This commit is contained in:
John Bro 2024-06-27 14:00:53 +08:00 committed by GitHub
parent 7c7d30376f
commit d00fb2163a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,20 +64,6 @@ type FileSearchInfo struct {
fs.FileInfo
}
func getDirSize(fs afero.Fs, path string) (int64, error) {
var size int64
err := afero.Walk(fs, path, func(p string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
size += info.Size()
}
return nil
})
return size, err
}
func NewFileInfo(op FileOption) (*FileInfo, error) {
var appFs = afero.NewOsFs()
@ -115,11 +101,6 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
}
if op.Expand {
if file.IsDir {
size, err := getDirSize(appFs, op.Path)
if err != nil {
return nil, err
}
file.Size = size
if err := file.listChildren(op); err != nil {
return nil, err
}