Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-07-17 22:18:38 +02:00
parent cc1d23a94c
commit f2ebeaa7e4
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
2 changed files with 12 additions and 4 deletions

View File

@ -229,7 +229,6 @@ type fsLockedRepo struct {
ds map[string]datastore.Batching ds map[string]datastore.Batching
dsErr error dsErr error
dsOnce sync.Once dsOnce sync.Once
dsLk sync.Mutex
storageLk sync.Mutex storageLk sync.Mutex
configLk sync.Mutex configLk sync.Mutex

View File

@ -81,6 +81,9 @@ func (mds *MultiStore) Get(i int) (*Store, error) {
var err error var err error
mds.open[i], err = openStore(wds) mds.open[i], err = openStore(wds)
if err != nil {
return nil, xerrors.Errorf("could not open new store: %w", err)
}
stores := make([]int, 0, len(mds.open)) stores := make([]int, 0, len(mds.open))
for k := range mds.open { for k := range mds.open {
@ -131,22 +134,28 @@ func (mds *MultiStore) Delete(i int) error {
if err != nil { if err != nil {
return xerrors.Errorf("query error: %w", err) return xerrors.Errorf("query error: %w", err)
} }
defer qres.Close() //nolint:errcheck
b, err := store.ds.Batch() b, err := store.ds.Batch()
if err != nil { if err != nil {
return xerrors.Errorf("batch error: %w", err) return xerrors.Errorf("batch error: %w", err)
} }
for r := range qres.Next() { for r := range qres.Next() {
if r.Error != nil { if r.Error != nil {
_ = qres.Close()
_ = b.Commit() _ = b.Commit()
return xerrors.Errorf("iterator error: %w", err) return xerrors.Errorf("iterator error: %w", err)
} }
b.Delete(datastore.NewKey(r.Key)) err := b.Delete(datastore.NewKey(r.Key))
if err != nil {
_ = b.Commit()
return xerrors.Errorf("adding to batch: %w", err)
}
} }
err = b.Commit() err = b.Commit()
if err != nil { if err != nil {
return xerrors.Errorf("commiting: %w", err) return xerrors.Errorf("committing: %w", err)
} }
return nil return nil