storage: Fix linter warnings
This commit is contained in:
parent
8cff52aef6
commit
d690b49d17
@ -99,6 +99,7 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {
|
|||||||
var localPath *storiface.StoragePath
|
var localPath *storiface.StoragePath
|
||||||
for _, lp := range lps {
|
for _, lp := range lps {
|
||||||
if lp.LocalPath == path {
|
if lp.LocalPath == path {
|
||||||
|
lp := lp // copy to make the linter happy
|
||||||
localPath = &lp
|
localPath = &lp
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -114,10 +115,11 @@ func (w *Worker) StorageDetachLocal(ctx context.Context, path string) error {
|
|||||||
for _, storagePath := range sc.StoragePaths {
|
for _, storagePath := range sc.StoragePaths {
|
||||||
if storagePath.Path != path {
|
if storagePath.Path != path {
|
||||||
out = append(out, storagePath)
|
out = append(out, storagePath)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
|
sc.StoragePaths = out
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return xerrors.Errorf("set storage config: %w", err)
|
return xerrors.Errorf("set storage config: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ func (i *Index) StorageDetach(ctx context.Context, id storiface.ID, url string)
|
|||||||
// ent: *storageEntry
|
// ent: *storageEntry
|
||||||
ent, ok := i.stores[id]
|
ent, ok := i.stores[id]
|
||||||
if !ok {
|
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
|
// check if this is the only path provider/url for this pathID
|
||||||
|
@ -267,12 +267,12 @@ func (st *Local) ClosePath(ctx context.Context, id storiface.ID) error {
|
|||||||
defer st.localLk.Unlock()
|
defer st.localLk.Unlock()
|
||||||
|
|
||||||
if _, exists := st.paths[id]; !exists {
|
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 {
|
for _, url := range st.urls {
|
||||||
if err := st.index.StorageDetach(ctx, id, url); err != nil {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +250,7 @@ func (m *Manager) DetachLocalStorage(ctx context.Context, path string) error {
|
|||||||
var localPath *storiface.StoragePath
|
var localPath *storiface.StoragePath
|
||||||
for _, lp := range lps {
|
for _, lp := range lps {
|
||||||
if lp.LocalPath == path {
|
if lp.LocalPath == path {
|
||||||
|
lp := lp // copy to make the linter happy
|
||||||
localPath = &lp
|
localPath = &lp
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -265,10 +266,11 @@ func (m *Manager) DetachLocalStorage(ctx context.Context, path string) error {
|
|||||||
for _, storagePath := range sc.StoragePaths {
|
for _, storagePath := range sc.StoragePaths {
|
||||||
if storagePath.Path != path {
|
if storagePath.Path != path {
|
||||||
out = append(out, storagePath)
|
out = append(out, storagePath)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
|
sc.StoragePaths = out
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return xerrors.Errorf("set storage config: %w", err)
|
return xerrors.Errorf("set storage config: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user