@@ -653,6 +653,9 @@ impl FilesystemStoreState {
653653 ' primary_loop: for primary_entry in fs:: read_dir ( prefixed_dest) ? {
654654 let primary_entry = primary_entry?;
655655 let primary_path = primary_entry. path ( ) ;
656+ if dir_entry_is_store_artifact ( & primary_path) {
657+ continue ' primary_loop;
658+ }
656659
657660 if dir_entry_is_key ( & primary_entry) ? {
658661 let primary_namespace = String :: new ( ) ;
@@ -666,6 +669,9 @@ impl FilesystemStoreState {
666669 ' secondary_loop: for secondary_entry in fs:: read_dir ( & primary_path) ? {
667670 let secondary_entry = secondary_entry?;
668671 let secondary_path = secondary_entry. path ( ) ;
672+ if dir_entry_is_store_artifact ( & secondary_path) {
673+ continue ' secondary_loop;
674+ }
669675
670676 if dir_entry_is_key ( & secondary_entry) ? {
671677 let primary_namespace = get_key_from_dir_entry_path (
@@ -683,6 +689,9 @@ impl FilesystemStoreState {
683689 for tertiary_entry in fs:: read_dir ( & secondary_path) ? {
684690 let tertiary_entry = tertiary_entry?;
685691 let tertiary_path = tertiary_entry. path ( ) ;
692+ if dir_entry_is_store_artifact ( & tertiary_path) {
693+ continue ;
694+ }
686695
687696 if dir_entry_is_key ( & tertiary_entry) ? {
688697 let primary_namespace = get_key_from_dir_entry_path (
@@ -720,20 +729,25 @@ impl FilesystemStoreState {
720729 }
721730}
722731
732+ fn dir_entry_is_store_artifact ( path : & Path ) -> bool {
733+ match path. extension ( ) . and_then ( |ext| ext. to_str ( ) ) {
734+ Some ( "tmp" ) => true ,
735+ Some ( "trash" ) => {
736+ #[ cfg( target_os = "windows" ) ]
737+ {
738+ // Clean up any trash files lying around.
739+ fs:: remove_file ( path) . ok ( ) ;
740+ }
741+ true
742+ } ,
743+ _ => false ,
744+ }
745+ }
746+
723747pub ( crate ) fn dir_entry_is_key ( dir_entry : & fs:: DirEntry ) -> Result < bool , lightning:: io:: Error > {
724748 let p = dir_entry. path ( ) ;
725- if let Some ( ext) = p. extension ( ) {
726- #[ cfg( target_os = "windows" ) ]
727- {
728- // Clean up any trash files lying around.
729- if ext == "trash" {
730- fs:: remove_file ( p) . ok ( ) ;
731- return Ok ( false ) ;
732- }
733- }
734- if ext == "tmp" {
735- return Ok ( false ) ;
736- }
749+ if dir_entry_is_store_artifact ( & p) {
750+ return Ok ( false ) ;
737751 }
738752
739753 let file_type = dir_entry. file_type ( ) ?;
0 commit comments