File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -195,8 +195,16 @@ impl Storage {
195
195
}
196
196
197
197
pub ( crate ) fn exists_in_archive ( & self , archive_path : & str , path : & str ) -> Result < bool > {
198
- let index = self . get_index_for ( archive_path) ?;
199
- Ok ( index. find_file ( path) . is_ok ( ) )
198
+ match self . get_index_for ( archive_path) {
199
+ Ok ( index) => Ok ( index. find_file ( path) . is_ok ( ) ) ,
200
+ Err ( err) => {
201
+ if err. downcast_ref :: < PathNotFoundError > ( ) . is_some ( ) {
202
+ Ok ( false )
203
+ } else {
204
+ Err ( err)
205
+ }
206
+ }
207
+ }
200
208
}
201
209
202
210
pub ( crate ) fn get ( & self , path : & str , max_size : usize ) -> Result < Blob > {
@@ -724,6 +732,13 @@ mod backend_tests {
724
732
Ok ( ( ) )
725
733
}
726
734
735
+ fn test_exists_without_remote_archive ( storage : & Storage ) -> Result < ( ) > {
736
+ // when remote and local index don't exist, any `exists_in_archive` should
737
+ // return `false`
738
+ assert ! ( !storage. exists_in_archive( "some_archive_name" , "some_file_name" ) ?) ;
739
+ Ok ( ( ) )
740
+ }
741
+
727
742
fn test_store_all_in_archive ( storage : & Storage , metrics : & Metrics ) -> Result < ( ) > {
728
743
let dir = tempfile:: Builder :: new ( )
729
744
. prefix ( "docs.rs-upload-archive-test" )
@@ -989,6 +1004,7 @@ mod backend_tests {
989
1004
test_get_too_big,
990
1005
test_delete_prefix,
991
1006
test_delete_percent,
1007
+ test_exists_without_remote_archive,
992
1008
}
993
1009
994
1010
tests_with_metrics {
You can’t perform that action at this time.
0 commit comments