@@ -14,8 +14,8 @@ use std::path::Path;
14
14
use crate :: controllers:: cargo_prelude:: * ;
15
15
use crate :: controllers:: util:: RequestPartsExt ;
16
16
use crate :: models:: {
17
- insert_version_owner_action, Category , Crate , DependencyKind , Keyword , NewCrate , NewVersion ,
18
- Rights , VersionAction ,
17
+ insert_version_owner_action, Category , Crate , Keyword , NewCrate , NewVersion , Rights ,
18
+ VersionAction ,
19
19
} ;
20
20
21
21
use crate :: middleware:: log_request:: RequestLogExt ;
@@ -208,9 +208,9 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
208
208
// to get here, and max upload sizes are way less than i32 max
209
209
content_length as i32 ,
210
210
user. id ,
211
- hex_cksum. clone ( ) ,
212
- links. clone ( ) ,
213
- rust_version. clone ( ) ,
211
+ hex_cksum,
212
+ links,
213
+ rust_version,
214
214
) ?
215
215
. save ( conn, & verified_email_address) ?;
216
216
@@ -343,11 +343,11 @@ pub fn add_dependencies(
343
343
conn : & mut PgConnection ,
344
344
deps : & [ EncodableCrateDependency ] ,
345
345
target_version_id : i32 ,
346
- ) -> AppResult < Vec < cargo_registry_index :: Dependency > > {
346
+ ) -> AppResult < ( ) > {
347
347
use self :: dependencies:: dsl:: * ;
348
348
use diesel:: insert_into;
349
349
350
- let git_and_new_dependencies = deps
350
+ let new_dependencies = deps
351
351
. iter ( )
352
352
. map ( |dep| {
353
353
if let Some ( registry) = & dep. registry {
@@ -367,51 +367,25 @@ pub fn add_dependencies(
367
367
}
368
368
}
369
369
370
- // If this dependency has an explicit name in `Cargo.toml` that
371
- // means that the `name` we have listed is actually the package name
372
- // that we're depending on. The `name` listed in the index is the
373
- // Cargo.toml-written-name which is what cargo uses for
374
- // `--extern foo=...`
375
- let ( name, package) = match & dep. explicit_name_in_toml {
376
- Some ( explicit) => ( explicit. to_string ( ) , Some ( dep. name . to_string ( ) ) ) ,
377
- None => ( dep. name . to_string ( ) , None ) ,
378
- } ;
379
-
380
370
Ok ( (
381
- cargo_registry_index:: Dependency {
382
- name,
383
- req : dep. version_req . to_string ( ) ,
384
- features : dep. features . iter ( ) . map ( |s| s. 0 . to_string ( ) ) . collect ( ) ,
385
- optional : dep. optional ,
386
- default_features : dep. default_features ,
387
- target : dep. target . clone ( ) ,
388
- kind : dep. kind . or ( Some ( DependencyKind :: Normal ) ) . map ( |dk| dk. into ( ) ) ,
389
- package,
390
- } ,
391
- (
392
- version_id. eq ( target_version_id) ,
393
- crate_id. eq ( krate. id ) ,
394
- req. eq ( dep. version_req . to_string ( ) ) ,
395
- dep. kind . map ( |k| kind. eq ( k as i32 ) ) ,
396
- optional. eq ( dep. optional ) ,
397
- default_features. eq ( dep. default_features ) ,
398
- features. eq ( & dep. features ) ,
399
- target. eq ( dep. target . as_deref ( ) ) ,
400
- explicit_name. eq ( dep. explicit_name_in_toml . as_deref ( ) )
401
- ) ,
371
+ version_id. eq ( target_version_id) ,
372
+ crate_id. eq ( krate. id ) ,
373
+ req. eq ( dep. version_req . to_string ( ) ) ,
374
+ dep. kind . map ( |k| kind. eq ( k as i32 ) ) ,
375
+ optional. eq ( dep. optional ) ,
376
+ default_features. eq ( dep. default_features ) ,
377
+ features. eq ( & dep. features ) ,
378
+ target. eq ( dep. target . as_deref ( ) ) ,
379
+ explicit_name. eq ( dep. explicit_name_in_toml . as_deref ( ) )
402
380
) )
403
381
} )
404
382
. collect :: < Result < Vec < _ > , _ > > ( ) ?;
405
383
406
- let ( mut git_deps, new_dependencies) : ( Vec < _ > , Vec < _ > ) =
407
- git_and_new_dependencies. into_iter ( ) . unzip ( ) ;
408
- git_deps. sort ( ) ;
409
-
410
384
insert_into ( dependencies)
411
385
. values ( & new_dependencies)
412
386
. execute ( conn) ?;
413
387
414
- Ok ( git_deps )
388
+ Ok ( ( ) )
415
389
}
416
390
417
391
#[ derive( Debug ) ]
0 commit comments