Skip to content

Commit e8297b1

Browse files
committed
fix: use github.com/vearutop/statigz to embed webUI srcs and improve Accept-Encoding handling
1 parent 59614d8 commit e8297b1

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ require (
7171
github.com/prometheus/procfs v0.16.1 // indirect
7272
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect
7373
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
74+
github.com/vearutop/statigz v1.5.0 // indirect
7475
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
7576
go.opentelemetry.io/otel v1.35.0 // indirect
7677
go.opentelemetry.io/otel/metric v1.35.0 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
164164
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
165165
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
166166
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
167+
github.com/vearutop/statigz v1.5.0 h1:FuWwZiT82yBw4xbWdWIawiP2XFTyEPhIo8upRxiKLqk=
168+
github.com/vearutop/statigz v1.5.0/go.mod h1:oHmjFf3izfCO804Di1ZjB666P3fAlVzJEx2k6jNt/Gk=
167169
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
168170
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
169171
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=

pkg/restic/restic.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ func (r *Repo) commandWithContext(ctx context.Context, args []string, opts ...Ge
5353
resolveOpts(opt, r.opts)
5454
resolveOpts(opt, opts)
5555

56-
fullCmd := append([]string{r.cmd}, args...)
57-
58-
if len(opt.prefixCmd) > 0 {
59-
fullCmd = append(slices.Clone(opt.prefixCmd), fullCmd...)
56+
var fullCmd []string
57+
fullCmd = append(fullCmd, opt.prefixCmd...)
58+
if r.cmd != "" {
59+
fullCmd = append(fullCmd, r.cmd)
6060
}
61-
61+
fullCmd = append(fullCmd, args...)
6262
fullCmd = append(fullCmd, opt.extraArgs...)
6363

6464
cmd := exec.CommandContext(ctx, fullCmd[0], fullCmd[1:]...)

webui/webui.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package webui
22

33
import (
44
"net/http"
5+
6+
"github.com/vearutop/statigz"
57
)
68

79
func Handler() http.Handler {
8-
10+
return statigz.FileServer(content, statigz.FSPrefix(contentPrefix))
911
}

webui/webui_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ func TestServeIndexNoGzip(t *testing.T) {
3838

3939
// Windows doesn't have the gzip binary, so we skip compression during the
4040
// go:generate step on Windows
41-
if runtime.GOOS != "windows" && rr.Header().Get("Content-Encoding") != "gzip" {
41+
if runtime.GOOS != "windows" && rr.Header().Get("Content-Encoding") != "" {
4242
t.Errorf("handler returned wrong content encoding: got %v want %v",
43-
rr.Header().Get("Content-Encoding"), "gzip")
43+
rr.Header().Get("Content-Encoding"), "")
4444
}
4545
}
4646

0 commit comments

Comments
 (0)