mirror of
https://github.com/Luzifer/preserve.git
synced 2024-12-20 17:51:18 +00:00
Lint: Fix linter issues
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a9687ec85b
commit
a2664f671c
2 changed files with 7 additions and 3 deletions
6
cache.go
6
cache.go
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue