diff --git a/Makefile b/Makefile index d1f96ea..16fe401 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.3.2 +VERSION = 1.3.3 APP := http-file-server PACKAGES := $(shell go list -f {{.Dir}} ./...) diff --git a/README.md b/README.md index e7d0f0b..90d9c77 100644 --- a/README.md +++ b/README.md @@ -60,14 +60,14 @@ Or [download a binary](https://github.com/sgreben/http-file-server/releases/late ```sh # Linux -curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.2/http-file-server_1.3.2_linux_x86_64.tar.gz | tar xz +curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.3/http-file-server_1.3.3_linux_x86_64.tar.gz | tar xz # OS X -curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.2/http-file-server_1.3.2_osx_x86_64.tar.gz | tar xz +curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.3/http-file-server_1.3.3_osx_x86_64.tar.gz | tar xz # Windows -curl -LO https://github.com/sgreben/http-file-server/releases/download/1.3.2/http-file-server_1.3.2_windows_x86_64.zip -unzip versions_1.3.2_windows_x86_64.zip +curl -LO https://github.com/sgreben/http-file-server/releases/download/1.3.3/http-file-server_1.3.3_windows_x86_64.zip +unzip versions_1.3.3_windows_x86_64.zip ``` ## Use it diff --git a/doc/screenshot.png b/doc/screenshot.png index f28a505..a8eed23 100644 Binary files a/doc/screenshot.png and b/doc/screenshot.png differ diff --git a/server.go b/server.go index cd8334d..eaa754c 100644 --- a/server.go +++ b/server.go @@ -3,6 +3,7 @@ package main import ( "fmt" "html/template" + "math" "net/http" "net/url" "os" @@ -65,17 +66,20 @@ func (f fileSizeBytes) String() string { MB = 1024 * KB GB = 1024 * MB ) + divBy := func(x int64) int { + return int(math.Round(float64(f) / float64(x))) + } switch { case f < KB: return fmt.Sprintf("%d", f) case f < MB: - return fmt.Sprintf("%dK", f/KB) + return fmt.Sprintf("%dK", divBy(KB)) case f < GB: - return fmt.Sprintf("%dM", f/MB) + return fmt.Sprintf("%dM", divBy(MB)) case f >= GB: fallthrough default: - return fmt.Sprintf("%dG", f/GB) + return fmt.Sprintf("%dG", divBy(GB)) } }