@@ -49,7 +49,7 @@ pub fn install(
49
49
let map = SourceConfigMap :: new ( config) ?;
50
50
51
51
let ( installed_anything, scheduled_error) = if krates. len ( ) <= 1 {
52
- install_one (
52
+ let pkg = determine_package (
53
53
config,
54
54
& root,
55
55
& map,
@@ -59,9 +59,13 @@ pub fn install(
59
59
vers,
60
60
opts,
61
61
force,
62
- no_track,
63
62
true ,
64
63
) ?;
64
+ if let Some ( pkg) = pkg {
65
+ install_one (
66
+ config, & root, source_id, from_cwd, vers, opts, force, no_track, pkg,
67
+ ) ?;
68
+ }
65
69
( true , false )
66
70
} else {
67
71
let mut succeeded = vec ! [ ] ;
@@ -72,7 +76,7 @@ pub fn install(
72
76
for krate in krates {
73
77
let root = root. clone ( ) ;
74
78
let map = map. clone ( ) ;
75
- match install_one (
79
+ let pkg = match determine_package (
76
80
config,
77
81
& root,
78
82
& map,
@@ -82,18 +86,34 @@ pub fn install(
82
86
vers,
83
87
opts,
84
88
force,
85
- no_track,
86
89
!did_update,
87
90
) {
88
- Ok ( still_needs_update) => {
91
+ Ok ( Some ( pkg) ) => {
92
+ did_update = true ;
93
+ pkg
94
+ }
95
+ Ok ( None ) => {
96
+ // Already installed
89
97
succeeded. push ( krate) ;
90
- did_update |= !still_needs_update ;
98
+ continue ;
91
99
}
92
100
Err ( e) => {
93
101
crate :: display_error ( & e, & mut config. shell ( ) ) ;
94
102
failed. push ( krate) ;
95
103
// We assume an update was performed if we got an error.
96
104
did_update = true ;
105
+ continue ;
106
+ }
107
+ } ;
108
+ match install_one (
109
+ config, & root, source_id, from_cwd, vers, opts, force, no_track, pkg,
110
+ ) {
111
+ Ok ( ( ) ) => {
112
+ succeeded. push ( krate) ;
113
+ }
114
+ Err ( e) => {
115
+ crate :: display_error ( & e, & mut config. shell ( ) ) ;
116
+ failed. push ( krate) ;
97
117
}
98
118
}
99
119
}
@@ -138,12 +158,8 @@ pub fn install(
138
158
Ok ( ( ) )
139
159
}
140
160
141
- // Returns whether a subsequent call should attempt to update again.
142
- // The `needs_update_if_source_is_index` parameter indicates whether or not the source index should
143
- // be updated. This is used ensure it is only updated once when installing multiple crates.
144
- // The return value here is used so that the caller knows what to pass to the
145
- // `needs_update_if_source_is_index` parameter when `install_one` is called again.
146
- fn install_one (
161
+ // Returns pkg to install. None if pkg is already installed
162
+ fn determine_package (
147
163
config : & Config ,
148
164
root : & Filesystem ,
149
165
map : & SourceConfigMap < ' _ > ,
@@ -153,9 +169,8 @@ fn install_one(
153
169
vers : Option < & str > ,
154
170
opts : & ops:: CompileOptions ,
155
171
force : bool ,
156
- no_track : bool ,
157
172
needs_update_if_source_is_index : bool ,
158
- ) -> CargoResult < bool > {
173
+ ) -> CargoResult < Option < Package > > {
159
174
if let Some ( name) = krate {
160
175
if name == "." {
161
176
bail ! (
@@ -167,7 +182,6 @@ fn install_one(
167
182
}
168
183
169
184
let dst = root. join ( "bin" ) . into_path_unlocked ( ) ;
170
-
171
185
let pkg = {
172
186
let dep = {
173
187
if let Some ( krate) = krate {
@@ -241,7 +255,7 @@ fn install_one(
241
255
pkg
242
256
) ;
243
257
config. shell ( ) . status ( "Ignored" , & msg) ?;
244
- return Ok ( true ) ;
258
+ return Ok ( None ) ;
245
259
}
246
260
select_dep_pkg ( & mut source, dep, config, needs_update_if_source_is_index) ?
247
261
} else {
@@ -252,6 +266,21 @@ fn install_one(
252
266
)
253
267
}
254
268
} ;
269
+ Ok ( Some ( pkg) )
270
+ }
271
+
272
+ fn install_one (
273
+ config : & Config ,
274
+ root : & Filesystem ,
275
+ source_id : SourceId ,
276
+ from_cwd : bool ,
277
+ vers : Option < & str > ,
278
+ opts : & ops:: CompileOptions ,
279
+ force : bool ,
280
+ no_track : bool ,
281
+ pkg : Package ,
282
+ ) -> CargoResult < ( ) > {
283
+ let dst = root. join ( "bin" ) . into_path_unlocked ( ) ;
255
284
256
285
let ( mut ws, rustc, target) = make_ws_rustc_target ( config, opts, & source_id, pkg. clone ( ) ) ?;
257
286
// If we're installing in --locked mode and there's no `Cargo.lock` published
@@ -345,7 +374,7 @@ fn install_one(
345
374
pkg
346
375
) ;
347
376
config. shell ( ) . status ( "Ignored" , & msg) ?;
348
- return Ok ( false ) ;
377
+ return Ok ( ( ) ) ;
349
378
}
350
379
351
380
config. shell ( ) . status ( "Installing" , & pkg) ?;
@@ -500,7 +529,7 @@ fn install_one(
500
529
"Installed" ,
501
530
format ! ( "package `{}` {}" , pkg, executables( successful_bins. iter( ) ) ) ,
502
531
) ?;
503
- Ok ( false )
532
+ Ok ( ( ) )
504
533
} else {
505
534
if !to_install. is_empty ( ) {
506
535
config. shell ( ) . status (
@@ -525,7 +554,7 @@ fn install_one(
525
554
) ,
526
555
) ?;
527
556
}
528
- Ok ( false )
557
+ Ok ( ( ) )
529
558
}
530
559
}
531
560
0 commit comments