Skip to content

Commit 98f5335

Browse files
committed
Removed NewKrate taking a license file. Now, NewVersion will accept the license and validate it. Additionally, Made NewCrate.crate_or_update take an immutable self instead of mutable because it was no longer necessary.
1 parent 1747eee commit 98f5335

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/krate.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl<'a> NewCrate<'a> {
134134
self,
135135
conn: &PgConnection,
136136
uploader: i32,
137+
license_file: Option<&str>,
137138
) -> CargoResult<Crate> {
138139
use diesel::update;
139140

@@ -1076,10 +1077,11 @@ pub fn new(req: &mut Request) -> CargoResult<Response> {
10761077
documentation: new_crate.documentation.as_ref().map(|s| &**s),
10771078
readme: new_crate.readme.as_ref().map(|s| &**s),
10781079
repository: new_crate.repository.as_ref().map(|s| &**s),
1080+
license: new_crate.license.as_ref().map(|s| &**s),
10791081
max_upload_size: None,
10801082
};
1081-
1082-
let krate = persist.create_or_update(&conn, user.id)?;
1083+
let license_file = new_crate.license_file.as_ref().map(|s| &**s);
1084+
let krate = persist.create_or_update(&conn, user.id, license_file)?;
10831085

10841086
let owners = krate.owners(&conn)?;
10851087
if rights(req.app(), &owners, &user)? < Rights::Publish {
@@ -1106,14 +1108,14 @@ pub fn new(req: &mut Request) -> CargoResult<Response> {
11061108
return Err(human(&format_args!("max upload size is: {}", max)));
11071109
}
11081110

1111+
// This is only redundant for now. Eventually the duplication will be removed.
11091112
let license = new_crate.license.clone();
1110-
let license_file = new_crate.license_file.as_ref().map(|s| &**s);
11111113

11121114
// Persist the new version of this crate
11131115
let version = NewVersion::new(krate.id, vers, &features, license, license_file)?.save(
11141116
&conn,
11151117
&new_crate
1116-
.authors,
1118+
.authors
11171119
)?;
11181120

11191121
// Link this new version to all dependencies

0 commit comments

Comments
 (0)