Skip to content

Commit

Permalink
fix: don't calculate usage for files (#1973)
Browse files Browse the repository at this point in the history
* fix: use incorrect suffix and return no 500(#1972#1967)

* chore: set progress bar to small

Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>

* chore: refactoring

Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 13, 2022
1 parent dcf0bc6 commit 577c0ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
v-if="$router.currentRoute.path.includes('/files/')"
style="width: 90%; margin: 2em 2.5em 3em 2.5em"
>
<progress-bar :val="usage.usedPercentage" :size="large"></progress-bar>
<progress-bar :val="usage.usedPercentage" size="small"></progress-bar>
<br />
{{ usage.used }} of {{ usage.total }} used
</div>
Expand All @@ -102,9 +102,9 @@
>
<span> {{ version }}</span>
</span>
<span
><a @click="help">{{ $t("sidebar.help") }}</a></span
>
<span>
<a @click="help">{{ $t("sidebar.help") }}</a>
</span>
</p>
</nav>
</template>
Expand Down
7 changes: 7 additions & 0 deletions http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ var diskUsage = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (
return errToStatus(err), err
}
fPath := file.RealPath()
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
Expand Down

0 comments on commit 577c0ef

Please sign in to comment.