@@ -100,6 +100,49 @@ impl FsBlockStore {
100
100
}
101
101
}
102
102
}
103
+
104
+ async fn list0 ( & self ) -> Result < Vec < Cid > , Error > {
105
+ use futures:: future:: { ready, Either } ;
106
+ use futures:: stream:: { empty, TryStreamExt } ;
107
+ use tokio_stream:: wrappers:: ReadDirStream ;
108
+
109
+ let span = tracing:: trace_span!( "listing blocks" ) ;
110
+
111
+ async move {
112
+ let stream = ReadDirStream :: new ( fs:: read_dir ( self . path . clone ( ) ) . await ?) ;
113
+
114
+ // FIXME: written as a stream to make the Vec be BoxStream<'static, Cid>
115
+ let vec = stream
116
+ . and_then ( |d| async move {
117
+ // map over the shard directories
118
+ Ok ( if d. file_type ( ) . await ?. is_dir ( ) {
119
+ Either :: Left ( ReadDirStream :: new ( fs:: read_dir ( d. path ( ) ) . await ?) )
120
+ } else {
121
+ Either :: Right ( empty ( ) )
122
+ } )
123
+ } )
124
+ // flatten each
125
+ . try_flatten ( )
126
+ // convert the paths ending in ".data" into cid
127
+ . try_filter_map ( |d| {
128
+ let name = d. file_name ( ) ;
129
+ let path: & std:: path:: Path = name. as_ref ( ) ;
130
+
131
+ ready ( if path. extension ( ) != Some ( "data" . as_ref ( ) ) {
132
+ Ok ( None )
133
+ } else {
134
+ let maybe_cid = filestem_to_block_cid ( path. file_stem ( ) ) ;
135
+ Ok ( maybe_cid)
136
+ } )
137
+ } )
138
+ . try_collect :: < Vec < _ > > ( )
139
+ . await ?;
140
+
141
+ Ok ( vec)
142
+ }
143
+ . instrument ( span)
144
+ . await
145
+ }
103
146
}
104
147
105
148
#[ async_trait]
@@ -355,46 +398,7 @@ impl BlockStore for FsBlockStore {
355
398
}
356
399
357
400
async fn list ( & self ) -> Result < Vec < Cid > , Error > {
358
- use futures:: future:: { ready, Either } ;
359
- use futures:: stream:: { empty, TryStreamExt } ;
360
- use tokio_stream:: wrappers:: ReadDirStream ;
361
-
362
- let span = tracing:: trace_span!( "listing blocks" ) ;
363
-
364
- async move {
365
- let stream = ReadDirStream :: new ( fs:: read_dir ( self . path . clone ( ) ) . await ?) ;
366
-
367
- // FIXME: written as a stream to make the Vec be BoxStream<'static, Cid>
368
- let vec = stream
369
- . and_then ( |d| async move {
370
- // map over the shard directories
371
- Ok ( if d. file_type ( ) . await ?. is_dir ( ) {
372
- Either :: Left ( ReadDirStream :: new ( fs:: read_dir ( d. path ( ) ) . await ?) )
373
- } else {
374
- Either :: Right ( empty ( ) )
375
- } )
376
- } )
377
- // flatten each
378
- . try_flatten ( )
379
- // convert the paths ending in ".data" into cid
380
- . try_filter_map ( |d| {
381
- let name = d. file_name ( ) ;
382
- let path: & std:: path:: Path = name. as_ref ( ) ;
383
-
384
- ready ( if path. extension ( ) != Some ( "data" . as_ref ( ) ) {
385
- Ok ( None )
386
- } else {
387
- let maybe_cid = filestem_to_block_cid ( path. file_stem ( ) ) ;
388
- Ok ( maybe_cid)
389
- } )
390
- } )
391
- . try_collect :: < Vec < _ > > ( )
392
- . await ?;
393
-
394
- Ok ( vec)
395
- }
396
- . instrument ( span)
397
- . await
401
+ self . list0 ( ) . await
398
402
}
399
403
400
404
async fn wipe ( & self ) {
0 commit comments