Skip to content

Commit

Permalink
Merge pull request #532 from GRFreire/folder-size-crash
Browse files Browse the repository at this point in the history
Fix panic when trying to get folder size without needed permissions
  • Loading branch information
yorukot authored Dec 30, 2024
2 parents c6370eb + 945aeab commit 85f7f6f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/internal/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,15 @@ func calculateMD5Checksum(filePath string) (string, error) {
// Get directory total size
func dirSize(path string) int64 {
var size int64
filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
filepath.WalkDir(path, func(_ string, entry os.DirEntry, err error) error {
if err != nil {
outPutLog("Dir size function error", err)
}
if !info.IsDir() {
size += info.Size()
if !entry.IsDir() {
info, err := entry.Info()
if err == nil {
size += info.Size()
}
}
return err
})
Expand Down

0 comments on commit 85f7f6f

Please sign in to comment.