Skip to content

Commit

Permalink
chore: refactoring
Browse files Browse the repository at this point in the history
(cherry picked from commit d0830e7)
  • Loading branch information
o1egl authored and luozhangbiao committed Aug 29, 2022
1 parent 5240b36 commit 4ec818c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,19 @@ var diskUsage = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (
return errToStatus(err), err
}
fPath := file.RealPath()
if file.IsDir {
usage, err := disk.UsageWithContext(r.Context(), fPath)
if err != nil {
return errToStatus(err), err
}
return renderJSON(w, r, &DiskUsageResponse{
Total: usage.Total,
Used: usage.Used,
})
} else {
if !file.IsDir {
return renderJSON(w, r, &DiskUsageResponse{
Total: 0,
Used: 0,
})
}

usage, err := disk.UsageWithContext(r.Context(), fPath)
if err != nil {
return errToStatus(err), err
}
return renderJSON(w, r, &DiskUsageResponse{
Total: usage.Total,
Used: usage.Used,
})
})

0 comments on commit 4ec818c

Please sign in to comment.