Skip to content

Commit 1961032

Browse files
committed
Merge branch 'licenses' of github.com:baileyn/crates.io into licenses
2 parents e7c07fa + db1ab7e commit 1961032

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

src/krate.rs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub struct EncodableCrate {
103103
pub description: Option<String>,
104104
pub homepage: Option<String>,
105105
pub documentation: Option<String>,
106-
pub license: Option<String>,
107106
pub repository: Option<String>,
108107
pub links: CrateLinks,
109108
pub exact_match: bool,
@@ -133,14 +132,13 @@ pub struct NewCrate<'a> {
133132

134133
impl<'a> NewCrate<'a> {
135134
pub fn create_or_update(
136-
mut self,
135+
self,
137136
conn: &PgConnection,
138-
license_file: Option<&str>,
139137
uploader: i32,
140138
) -> CargoResult<Crate> {
141139
use diesel::update;
142140

143-
self.validate(license_file)?;
141+
self.validate()?;
144142
self.ensure_name_not_reserved(conn)?;
145143

146144
conn.transaction(|| {
@@ -161,7 +159,7 @@ impl<'a> NewCrate<'a> {
161159
})
162160
}
163161

164-
fn validate(&mut self, license_file: Option<&str>) -> CargoResult<()> {
162+
fn validate(&self) -> CargoResult<()> {
165163
fn validate_url(url: Option<&str>, field: &str) -> CargoResult<()> {
166164
let url = match url {
167165
Some(s) => s,
@@ -195,28 +193,6 @@ impl<'a> NewCrate<'a> {
195193
validate_url(self.homepage, "homepage")?;
196194
validate_url(self.documentation, "documentation")?;
197195
validate_url(self.repository, "repository")?;
198-
self.validate_license(license_file)?;
199-
Ok(())
200-
}
201-
202-
fn validate_license(&mut self, license_file: Option<&str>) -> CargoResult<()> {
203-
if let Some(license) = self.license {
204-
for part in license.split('/') {
205-
license_exprs::validate_license_expr(part).map_err(|e| {
206-
human(&format_args!(
207-
"{}; see http://opensource.org/licenses \
208-
for options, and http://spdx.org/licenses/ \
209-
for their identifiers",
210-
e
211-
))
212-
})?;
213-
}
214-
} else if license_file.is_some() {
215-
// If no license is given, but a license file is given, flag this
216-
// crate as having a nonstandard license. Note that we don't
217-
// actually do anything else with license_file currently.
218-
self.license = Some("non-standard");
219-
}
220196
Ok(())
221197
}
222198

@@ -503,7 +479,6 @@ impl Crate {
503479
description,
504480
homepage,
505481
documentation,
506-
license,
507482
repository,
508483
..
509484
} = self;
@@ -529,7 +504,6 @@ impl Crate {
529504
homepage: homepage,
530505
exact_match: exact_match,
531506
description: description,
532-
license: license,
533507
repository: repository,
534508
links: CrateLinks {
535509
version_downloads: format!("/api/v1/crates/{}/downloads", name),
@@ -1083,8 +1057,9 @@ pub fn new(req: &mut Request) -> CargoResult<Response> {
10831057
license: new_crate.license.as_ref().map(|s| &**s),
10841058
max_upload_size: None,
10851059
};
1060+
10861061
let license_file = new_crate.license_file.as_ref().map(|s| &**s);
1087-
let krate = persist.create_or_update(&conn, license_file, user.id)?;
1062+
let krate = persist.create_or_update(&conn, user.id)?;
10881063

10891064
let owners = krate.owners(&conn)?;
10901065
if rights(req.app(), &owners, &user)? < Rights::Publish {

src/tests/all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ impl<'a> CrateBuilder<'a> {
325325

326326
let mut krate = self.krate.create_or_update(
327327
connection,
328-
None,
329328
self.owner_id,
330329
)?;
331330

0 commit comments

Comments
 (0)