Skip to content

Commit 5d698ec

Browse files
fix linting warnings
1 parent c0128c1 commit 5d698ec

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

fuse/mount.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func MountFS(mountpoint string, files []File) (func(), error) {
2727
if err != nil {
2828
return nil, fmt.Errorf("failed to mount filesystem: %w", err)
2929
}
30-
close := func() {
30+
closeFS := func() {
3131
clog.Debug("unmounting filesystem")
3232
err := server.Unmount() // don't need to call Wait after Unmount
3333
if err != nil {
@@ -36,5 +36,5 @@ func MountFS(mountpoint string, files []File) (func(), error) {
3636

3737
memFS.Close()
3838
}
39-
return close, nil
39+
return closeFS, nil
4040
}

remote.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"archive/tar"
55
"bytes"
6+
"context"
67
"encoding/json"
78
"fmt"
89
"io"
@@ -22,7 +23,7 @@ func loadRemoteFiles(endpoint string) ([]fuse.File, *remote.Manifest, error) {
2223
var parameters *remote.Manifest
2324

2425
client := http.DefaultClient
25-
request, err := http.NewRequest("GET", endpoint, http.NoBody)
26+
request, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, endpoint, http.NoBody)
2627
if err != nil {
2728
return nil, nil, fmt.Errorf("failed to create request: %w", err)
2829
}

send.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func sendProfileCommand(w io.Writer, cmdCtx commandContext) error {
3737
if err != nil {
3838
resp.Header().Set("Content-Type", "text/plain")
3939
resp.WriteHeader(http.StatusInternalServerError)
40-
resp.Write([]byte(err.Error()))
40+
_, _ = resp.Write([]byte(err.Error()))
4141
return
4242
}
4343

@@ -46,8 +46,8 @@ func sendProfileCommand(w io.Writer, cmdCtx commandContext) error {
4646

4747
tar := remote.NewTar(resp)
4848
defer tar.Close()
49-
tar.SendFiles(afero.NewOsFs(), append(remoteConfig.SendFiles, remoteConfig.ConfigurationFile))
50-
tar.SendFile(constants.ManifestFilename, manifestData)
49+
_ = tar.SendFiles(afero.NewOsFs(), append(remoteConfig.SendFiles, remoteConfig.ConfigurationFile))
50+
_ = tar.SendFile(constants.ManifestFilename, manifestData)
5151
})
5252
cnx := ssh.NewSSH(ssh.Config{
5353
Host: remoteConfig.Host,

serve.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ func serveCommand(w io.Writer, cmdCtx commandContext) error {
2727
if !cmdCtx.config.HasRemote(remoteName) {
2828
resp.Header().Set("Content-Type", "text/plain")
2929
resp.WriteHeader(http.StatusNotFound)
30-
resp.Write([]byte("remote not found"))
30+
_, _ = resp.Write([]byte("remote not found"))
3131
return
3232
}
3333
remoteConfig, err := cmdCtx.config.GetRemote(remoteName)
3434
if err != nil {
3535
resp.Header().Set("Content-Type", "text/plain")
3636
resp.WriteHeader(http.StatusBadRequest)
37-
resp.Write([]byte(err.Error()))
37+
_, _ = resp.Write([]byte(err.Error()))
3838
return
3939
}
4040

@@ -47,7 +47,7 @@ func serveCommand(w io.Writer, cmdCtx commandContext) error {
4747
if err != nil {
4848
resp.Header().Set("Content-Type", "text/plain")
4949
resp.WriteHeader(http.StatusInternalServerError)
50-
resp.Write([]byte(err.Error()))
50+
_, _ = resp.Write([]byte(err.Error()))
5151
return
5252
}
5353

@@ -57,8 +57,8 @@ func serveCommand(w io.Writer, cmdCtx commandContext) error {
5757

5858
tar := remote.NewTar(resp)
5959
defer tar.Close()
60-
tar.SendFiles(afero.NewOsFs(), append(remoteConfig.SendFiles, remoteConfig.ConfigurationFile))
61-
tar.SendFile(constants.ManifestFilename, manifestData)
60+
_ = tar.SendFiles(afero.NewOsFs(), append(remoteConfig.SendFiles, remoteConfig.ConfigurationFile))
61+
_ = tar.SendFile(constants.ManifestFilename, manifestData)
6262

6363
})
6464

@@ -67,8 +67,9 @@ func serveCommand(w io.Writer, cmdCtx commandContext) error {
6767
defer signal.Stop(quit)
6868

6969
server := &http.Server{
70-
Addr: fmt.Sprintf("localhost:%s", cmdCtx.flags.resticArgs[1]),
71-
Handler: handler,
70+
Addr: fmt.Sprintf("localhost:%s", cmdCtx.flags.resticArgs[1]),
71+
Handler: handler,
72+
ReadHeaderTimeout: 5 * time.Second,
7273
}
7374

7475
// put the shutdown code in a goroutine

ssh/ssh.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func (s *SSH) Connect() error {
7676

7777
go func() {
7878
s.server = &http.Server{
79-
Handler: s.config.Handler,
79+
Handler: s.config.Handler,
80+
ReadHeaderTimeout: 5 * time.Second,
8081
}
8182
// Serve HTTP with your SSH server acting as a reverse proxy.
8283
err := s.server.Serve(s.tunnel)

0 commit comments

Comments
 (0)