File tree 4 files changed +19
-5
lines changed
4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 81
81
"ipfs-utils" : " ^6.0.0" ,
82
82
"ipld-block" : " ^0.11.0" ,
83
83
"it-filter" : " ^1.0.2" ,
84
- "it-map" : " ^1.0.2" ,
85
84
"it-pushable" : " ^1.4.0" ,
86
85
"just-safe-get" : " ^2.0.0" ,
87
86
"just-safe-set" : " ^2.1.0" ,
Original file line number Diff line number Diff line change 3
3
const { shard, ShardingDatastore } = require ( 'datastore-core' )
4
4
const Block = require ( 'ipld-block' )
5
5
const { cidToKey, keyToCid } = require ( './blockstore-utils' )
6
- const map = require ( 'it-map' )
7
6
const drain = require ( 'it-drain' )
8
7
const pushable = require ( 'it-pushable' )
9
8
/**
@@ -135,7 +134,21 @@ function createBaseStore (store) {
135
134
} ,
136
135
137
136
deleteMany ( cids , options ) {
138
- return store . deleteMany ( map ( cids , cid => cidToKey ( cid ) ) , options )
137
+ const out = pushable ( )
138
+
139
+ drain ( store . deleteMany ( ( async function * ( ) {
140
+ for await ( const cid of cids ) {
141
+ yield cidToKey ( cid )
142
+
143
+ out . push ( cid )
144
+ }
145
+
146
+ out . end ( )
147
+ } ( ) ) , options ) ) . catch ( err => {
148
+ out . end ( err )
149
+ } )
150
+
151
+ return out
139
152
} ,
140
153
141
154
close ( ) {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export interface Blockstore {
105
105
/**
106
106
* Delete a block from the store
107
107
*/
108
- deleteMany : ( cids : AwaitIterable < any > , options ?: DatastoreOptions ) => AsyncIterable < Key >
108
+ deleteMany : ( cids : AwaitIterable < any > , options ?: DatastoreOptions ) => AsyncIterable < CID >
109
109
110
110
/**
111
111
* Close the store
Original file line number Diff line number Diff line change @@ -440,9 +440,11 @@ module.exports = (repo) => {
440
440
441
441
describe ( '.deleteMany' , ( ) => {
442
442
it ( 'simple' , async ( ) => {
443
- await drain ( repo . blocks . deleteMany ( [ b . cid ] ) )
443
+ const deleted = await all ( repo . blocks . deleteMany ( [ b . cid ] ) )
444
444
const exists = await repo . blocks . has ( b . cid )
445
445
expect ( exists ) . to . equal ( false )
446
+ expect ( deleted ) . to . have . lengthOf ( 1 )
447
+ expect ( deleted [ 0 ] ) . to . deep . equal ( b . cid )
446
448
} )
447
449
448
450
it ( 'including identity cid' , async ( ) => {
You can’t perform that action at this time.
0 commit comments