resolve linter issues
This commit is contained in:
@@ -36,7 +36,7 @@ func (s WebDav) Get(ctx context.Context, file string) (image.Image, error) {
|
||||
return nil, errors.Wrapf(err, `could not get the image "%s"`, file)
|
||||
}
|
||||
|
||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: s.insecure}
|
||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: s.insecure} //nolint:gosec
|
||||
|
||||
auth, ok := ContextGetAuthorization(ctx)
|
||||
if !ok {
|
||||
@@ -49,6 +49,7 @@ func (s WebDav) Get(ctx context.Context, file string) (image.Image, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, `could not get the image "%s"`, file)
|
||||
}
|
||||
defer resp.Body.Close() //nolint:errcheck
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("could not get the image \"%s\". Request returned with statuscode %d ", file, resp.StatusCode)
|
||||
|
||||
@@ -93,8 +93,7 @@ func TestClosestMatch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseWithEmptyString(t *testing.T) {
|
||||
_, err := ParseResolution("")
|
||||
if err == nil {
|
||||
if _, err := ParseResolution(""); err == nil {
|
||||
t.Error("Parse with empty string should return an error.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,9 @@ func (s *FileSystem) storeImage(key string, img []byte) (string, error) {
|
||||
// This will balance the folders in setups with many users.
|
||||
func (s *FileSystem) userDir(username string) string {
|
||||
hash := sha256.New224()
|
||||
hash.Write([]byte(username))
|
||||
if _, err := hash.Write([]byte(username)); err != nil {
|
||||
s.logger.Fatal().Err(err).Msg("failed to create hash")
|
||||
}
|
||||
unHash := hex.EncodeToString(hash.Sum(nil)) // 224 Bits or 224 / 4 = 56 characters.
|
||||
|
||||
return filepath.Join(s.root, usersDir, unHash[:3], unHash[3:6], unHash[6:])
|
||||
|
||||
@@ -42,6 +42,6 @@ func BenchmarkGet(b *testing.B) {
|
||||
img, ext, _ := image.Decode(f)
|
||||
req.Encoder = EncoderForType(ext)
|
||||
for i := 0; i < b.N; i++ {
|
||||
sut.Get(req, img)
|
||||
_, _ = sut.Get(req, img)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user