storage: Fix linter warnings

This commit is contained in:
Łukasz Magiera 2022-07-15 12:56:03 +02:00
parent 8cff52aef6
commit d690b49d17
4 changed files with 9 additions and 5 deletions

View File

@ -99,6 +99,7 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {
var localPath *storiface.StoragePath
for _, lp := range lps {
if lp.LocalPath == path {
lp := lp // copy to make the linter happy
localPath = &lp
break
}
@ -114,10 +115,11 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {
for _, storagePath := range sc.StoragePaths {
if storagePath.Path != path {
out = append(out, storagePath)
return
continue
}
found = true
}
sc.StoragePaths = out
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
}

View File

@ -225,7 +225,7 @@ func (i *Index) StorageDetach(ctx context.Context, id storiface.ID, url string)
// ent: *storageEntry
ent, ok := i.stores[id]
if !ok {
return xerrors.Errorf("storage '%s' isn't registerd", id)
return xerrors.Errorf("storage '%s' isn't registered", id)
}
// check if this is the only path provider/url for this pathID

View File

@ -267,12 +267,12 @@ func (st *Local) ClosePath(ctx context.Context, id storiface.ID) error {
defer st.localLk.Unlock()
if _, exists := st.paths[id]; !exists {
return xerrors.Errorf("path with ID %s isn't opened")
return xerrors.Errorf("path with ID %s isn't opened", id)
}
for _, url := range st.urls {
if err := st.index.StorageDetach(ctx, id, url); err != nil {
return xerrors.Errorf("dropping path (id='%s' url=''): %w", id, url, err)
return xerrors.Errorf("dropping path (id='%s' url='%s'): %w", id, url, err)
}
}

View File

@ -250,6 +250,7 @@ func (m *Manager) DetachLocalStorage(ctx context.Context, path string) error {
var localPath *storiface.StoragePath
for _, lp := range lps {
if lp.LocalPath == path {
lp := lp // copy to make the linter happy
localPath = &lp
break
}
@ -265,10 +266,11 @@ func (m *Manager) DetachLocalStorage(ctx context.Context, path string) error {
for _, storagePath := range sc.StoragePaths {
if storagePath.Path != path {
out = append(out, storagePath)
return
continue
}
found = true
}
sc.StoragePaths = out
}); err != nil {
return xerrors.Errorf("set storage config: %w", err)
}