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
dsErr error
dsOnce sync.Once
dsLk sync.Mutex
storageLk sync.Mutex
configLk sync.Mutex

View File

@ -81,6 +81,9 @@ func (mds *MultiStore) Get(i int) (*Store, error) {
var err error
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))
for k := range mds.open {
@ -131,22 +134,28 @@ func (mds *MultiStore) Delete(i int) error {
if err != nil {
return xerrors.Errorf("query error: %w", err)
}
defer qres.Close() //nolint:errcheck
b, err := store.ds.Batch()
if err != nil {
return xerrors.Errorf("batch error: %w", err)
}
for r := range qres.Next() {
if r.Error != nil {
_ = qres.Close()
_ = b.Commit()
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()
if err != nil {
return xerrors.Errorf("commiting: %w", err)
return xerrors.Errorf("committing: %w", err)
}
return nil