Fix error handling in LoadIndexes

This commit is contained in:
Patrick Pacher 2022-10-11 11:50:47 +02:00
parent 8471f4f38a
commit 2b4c15c1f7
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/fs"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -102,7 +103,7 @@ func (reg *ResourceRegistry) LoadIndexes(ctx context.Context) error {
} else if reg.Online { } else if reg.Online {
// try to download the index file if a local disk version // try to download the index file if a local disk version
// does not exist or we don't have permission to read it. // does not exist or we don't have permission to read it.
if os.IsNotExist(err) || os.IsPermission(err) { if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) {
err = reg.downloadIndex(ctx, client, idx) err = reg.downloadIndex(ctx, client, idx)
} }
} }