1
0

Updated use of convertFileSize() in a ScanDirectory() function.

This commit is contained in:
Alexander Andreev 2022-12-17 22:46:17 +04:00
parent 0798ba6602
commit 920f9f08ee
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -52,12 +52,11 @@ func ScanDirectory(path, urlBase string) (entries []DirEntry, stats DirStats, er
}) })
stats.Directories++ stats.Directories++
} else { } else {
_, _, sz := convertFileSize(entry.Size())
fileEntries = append(fileEntries, DirEntry{ fileEntries = append(fileEntries, DirEntry{
Name: entry.Name(), Name: entry.Name(),
Link: "/file" + urlBase + url.PathEscape(entry.Name()), Link: "/file" + urlBase + url.PathEscape(entry.Name()),
Datetime: entry.ModTime(), Datetime: entry.ModTime(),
Size: sz, Size: convertFileSize(entry.Size()),
}) })
totalFilesSize += entry.Size() totalFilesSize += entry.Size()
@ -65,8 +64,7 @@ func ScanDirectory(path, urlBase string) (entries []DirEntry, stats DirStats, er
} }
} }
_, _, sz := convertFileSize(totalFilesSize) stats.FilesSize = convertFileSize(totalFilesSize)
stats.FilesSize = sz
entries = append(entries, dirEntries...) entries = append(entries, dirEntries...)
entries = append(entries, fileEntries...) entries = append(entries, fileEntries...)