Display bytes written to response instead of size of files being served in logs

This commit is contained in:
Seednode 2023-09-15 15:30:52 -05:00
parent 7d49a86e70
commit 16d1428a52
4 changed files with 7 additions and 9 deletions

View File

@ -11,7 +11,7 @@ import (
)
const (
ReleaseVersion string = "0.90.1"
ReleaseVersion string = "0.90.3"
)
var (

View File

@ -96,9 +96,7 @@ func serveStaticFile(paths []string, cache *fileCache, errorChannel chan<- error
return
}
w.Write(buf)
fileSize := humanReadableSize(len(buf))
written, _ := w.Write(buf)
refererUri, err := stripQueryParams(refererToUri(r.Referer()))
if err != nil {
@ -124,7 +122,7 @@ func serveStaticFile(paths []string, cache *fileCache, errorChannel chan<- error
fmt.Printf("%s | Serve: %s (%s) to %s in %s\n",
startTime.Format(logDate),
filePath,
fileSize,
humanReadableSize(written),
realIP(r),
time.Since(startTime).Round(time.Microsecond),
)
@ -296,7 +294,7 @@ func serveMedia(paths []string, regexes *regexes, cache *fileCache, formats *typ
formattedPage := gohtml.Format(htmlBody.String())
_, err = io.WriteString(w, formattedPage)
written, err := io.WriteString(w, formattedPage)
if err != nil {
errorChannel <- err
@ -310,7 +308,7 @@ func serveMedia(paths []string, regexes *regexes, cache *fileCache, formats *typ
fmt.Printf("%s | Serve: %s (%s) to %s in %s\n",
startTime.Format(logDate),
path,
humanReadableSize(len(formattedPage)),
humanReadableSize(written),
realIP(r),
time.Since(startTime).Round(time.Microsecond),
)

View File

@ -222,7 +222,7 @@ func (t Format) Validate(filePath string) bool {
}
func (t Format) Type() string {
return "html"
return "inline"
}
func New(theme string) Format {

View File

@ -77,7 +77,7 @@ func (t Format) Validate(filePath string) bool {
}
func (t Format) Type() string {
return "html"
return "inline"
}
func New() Format {