1
0
Fork 0
mirror of https://github.com/Luzifer/preserve.git synced 2024-11-08 14:20:05 +00:00

Lint: Fix linter issues

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-11-05 17:26:15 +01:00
parent a9687ec85b
commit a2664f671c
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 7 additions and 3 deletions

View file

@ -11,10 +11,12 @@ import (
"github.com/pkg/errors"
)
const lastSuccessStatus = 299
func renewCache(ctx context.Context, url string) (*meta, error) {
cachePath := urlToCachePath(url)
req, err := http.NewRequest(http.MethodGet, url, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, errors.Wrap(err, "Unable to create request")
}
@ -29,7 +31,7 @@ func renewCache(ctx context.Context, url string) (*meta, error) {
}
defer resp.Body.Close()
if resp.StatusCode > 299 {
if resp.StatusCode > lastSuccessStatus {
return nil, errors.Errorf("HTTP status signaled failure: %d", resp.StatusCode)
}

View file

@ -12,6 +12,8 @@ import (
"github.com/pkg/errors"
)
const storageLocalDirPermission = 0o700
type storageLocal struct {
basePath string
}
@ -47,7 +49,7 @@ func (s storageLocal) LoadMeta(ctx context.Context, cachePath string) (*meta, er
func (s storageLocal) StoreFile(ctx context.Context, cachePath string, metadata *meta, data io.Reader) (err error) {
cachePath = path.Join(s.basePath, cachePath)
if err = os.MkdirAll(path.Dir(cachePath), 0700); err != nil {
if err = os.MkdirAll(path.Dir(cachePath), storageLocalDirPermission); err != nil {
return errors.Wrap(err, "create cache dir")
}