File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
src/cargo/sources/registry Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ use crate::util::errors::CargoResult;
4
4
use crate :: util:: { Config , Filesystem } ;
5
5
use cargo_util:: { paths, Sha256 } ;
6
6
use std:: fs:: File ;
7
- use std:: io:: prelude:: * ;
8
7
use std:: io:: SeekFrom ;
8
+ use std:: io:: { self , prelude:: * } ;
9
9
use std:: path:: Path ;
10
10
use std:: task:: Poll ;
11
11
@@ -54,8 +54,17 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> {
54
54
_index_version : Option < & str > ,
55
55
) -> Poll < CargoResult < LoadResponse > > {
56
56
if self . updated {
57
+ let raw_data = match paths:: read_bytes ( & root. join ( path) ) {
58
+ Err ( e)
59
+ if e. downcast_ref :: < io:: Error > ( )
60
+ . map_or ( false , |ioe| ioe. kind ( ) == io:: ErrorKind :: NotFound ) =>
61
+ {
62
+ return Poll :: Ready ( Ok ( LoadResponse :: NotFound ) ) ;
63
+ }
64
+ r => r,
65
+ } ?;
57
66
Poll :: Ready ( Ok ( LoadResponse :: Data {
58
- raw_data : paths :: read_bytes ( & root . join ( path ) ) ? ,
67
+ raw_data,
59
68
index_version : None ,
60
69
} ) )
61
70
} else {
Original file line number Diff line number Diff line change @@ -62,6 +62,44 @@ fn simple() {
62
62
p. cargo ( "test" ) . run ( ) ;
63
63
}
64
64
65
+ #[ cargo_test]
66
+ fn not_found ( ) {
67
+ setup ( ) ;
68
+ // Publish a package so that the directory hierarchy is created.
69
+ // Note, however, that we declare a dependency on baZ.
70
+ Package :: new ( "bar" , "0.0.1" ) . local ( true ) . publish ( ) ;
71
+
72
+ let p = project ( )
73
+ . file (
74
+ "Cargo.toml" ,
75
+ r#"
76
+ [project]
77
+ name = "foo"
78
+ version = "0.0.1"
79
+ authors = []
80
+
81
+ [dependencies]
82
+ baz = "0.0.1"
83
+ "# ,
84
+ )
85
+ . file (
86
+ "src/lib.rs" ,
87
+ "extern crate baz; pub fn foo() { baz::bar(); }" ,
88
+ )
89
+ . build ( ) ;
90
+
91
+ p. cargo ( "build" )
92
+ . with_status ( 101 )
93
+ . with_stderr (
94
+ "\
95
+ [ERROR] no matching package named `baz` found
96
+ location searched: registry `crates-io`
97
+ required by package `foo v0.0.1 ([..]/foo)`
98
+ " ,
99
+ )
100
+ . run ( ) ;
101
+ }
102
+
65
103
#[ cargo_test]
66
104
fn depend_on_yanked ( ) {
67
105
setup ( ) ;
You can’t perform that action at this time.
0 commit comments