Storage size computing moved off to utils.DirectorySize().
This commit is contained in:
parent
36b0dc7b4d
commit
be37f74317
@ -11,11 +11,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eknkc/amber"
|
"github.com/eknkc/amber"
|
||||||
@ -65,16 +63,11 @@ func (h *UploadHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
|||||||
var fMaxSize int64 = h.conf.Uploads.Limits.FileSize << 20
|
var fMaxSize int64 = h.conf.Uploads.Limits.FileSize << 20
|
||||||
var storSize int64 = 0
|
var storSize int64 = 0
|
||||||
|
|
||||||
filepath.Walk(h.conf.Uploads.Directory, func(_ string, info fs.FileInfo, err error) error {
|
storSize, err := utils.DirectorySize(h.conf.Uploads.Directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
h.logErr.Printf("cannot compute storage size: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
storSize += info.Size()
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
_, _, capStr := utils.ConvertFileSize(storCapacity)
|
_, _, capStr := utils.ConvertFileSize(storCapacity)
|
||||||
_, _, usedStr := utils.ConvertFileSize(storSize)
|
_, _, usedStr := utils.ConvertFileSize(storSize)
|
||||||
_, _, availStr := utils.ConvertFileSize(storCapacity - storSize)
|
_, _, availStr := utils.ConvertFileSize(storCapacity - storSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user