fix: don't calculate usage for files (#1973)

* 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>
pull/2013/head
langren1353 2022-06-13 18:50:39 +08:00 committed by GitHub
parent dcf0bc65bf
commit 577c0efa9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -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>
@ -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>

View File

@ -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