Skip to content

Commit e7c07fa

Browse files
committed
Added the license fields back to the Crate/EncodableCrate so that they can still be used in production.
1 parent 8ed3be0 commit e7c07fa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/krate.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub struct EncodableCrate {
103103
pub description: Option<String>,
104104
pub homepage: Option<String>,
105105
pub documentation: Option<String>,
106+
pub license: Option<String>,
106107
pub repository: Option<String>,
107108
pub links: CrateLinks,
108109
pub exact_match: bool,
@@ -127,18 +128,19 @@ pub struct NewCrate<'a> {
127128
pub readme: Option<&'a str>,
128129
pub repository: Option<&'a str>,
129130
pub max_upload_size: Option<i32>,
131+
pub license: Option<&'a str>,
130132
}
131133

132134
impl<'a> NewCrate<'a> {
133135
pub fn create_or_update(
134-
self,
136+
mut self,
135137
conn: &PgConnection,
136138
license_file: Option<&str>,
137139
uploader: i32,
138140
) -> CargoResult<Crate> {
139141
use diesel::update;
140142

141-
self.validate()?;
143+
self.validate(license_file)?;
142144
self.ensure_name_not_reserved(conn)?;
143145

144146
conn.transaction(|| {
@@ -159,7 +161,7 @@ impl<'a> NewCrate<'a> {
159161
})
160162
}
161163

162-
fn validate(&self) -> CargoResult<()> {
164+
fn validate(&mut self, license_file: Option<&str>) -> CargoResult<()> {
163165
fn validate_url(url: Option<&str>, field: &str) -> CargoResult<()> {
164166
let url = match url {
165167
Some(s) => s,
@@ -501,6 +503,7 @@ impl Crate {
501503
description,
502504
homepage,
503505
documentation,
506+
license,
504507
repository,
505508
..
506509
} = self;
@@ -526,6 +529,7 @@ impl Crate {
526529
homepage: homepage,
527530
exact_match: exact_match,
528531
description: description,
532+
license: license,
529533
repository: repository,
530534
links: CrateLinks {
531535
version_downloads: format!("/api/v1/crates/{}/downloads", name),

src/tests/all.rs

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

326326
let mut krate = self.krate.create_or_update(
327327
connection,
328-
self.license_file,
328+
None,
329329
self.owner_id,
330330
)?;
331331

0 commit comments

Comments
 (0)