@@ -281,11 +281,27 @@ impl KVStore for FilesystemStore {
281
281
return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
282
282
}
283
283
284
- if let Some ( relative_path) = p. strip_prefix ( & prefixed_dest) . ok ( )
285
- . and_then ( |p| p. to_str ( ) ) {
286
- if relative_path. chars ( ) . all ( |c| c. is_ascii ( ) && !c. is_control ( ) ) {
287
- keys. push ( relative_path. to_string ( ) )
284
+ match p. strip_prefix ( & prefixed_dest) {
285
+ Ok ( stripped_path) => {
286
+ if let Some ( relative_path) = stripped_path. to_str ( ) {
287
+ if relative_path. chars ( ) . all ( |c| c. is_ascii ( ) && !c. is_control ( ) ) {
288
+ keys. push ( relative_path. to_string ( ) )
289
+ }
290
+ } else {
291
+ debug_assert ! ( false , "Failed to list keys of namespace {}: file path is not valid UTF-8" ,
292
+ PrintableString ( namespace) ) ;
293
+ let msg = format ! ( "Failed to list keys of namespace {}: file path is not valid UTF-8" ,
294
+ PrintableString ( namespace) ) ;
295
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
288
296
}
297
+ }
298
+ Err ( e) => {
299
+ debug_assert ! ( false , "Failed to list keys of namespace {}: {}" ,
300
+ PrintableString ( namespace) , e) ;
301
+ let msg = format ! ( "Failed to list keys of namespace {}: {}" ,
302
+ PrintableString ( namespace) , e) ;
303
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
304
+ }
289
305
}
290
306
}
291
307
0 commit comments