@@ -103,6 +103,7 @@ pub struct EncodableCrate {
103
103
pub description : Option < String > ,
104
104
pub homepage : Option < String > ,
105
105
pub documentation : Option < String > ,
106
+ pub license : Option < String > ,
106
107
pub repository : Option < String > ,
107
108
pub links : CrateLinks ,
108
109
pub exact_match : bool ,
@@ -127,18 +128,19 @@ pub struct NewCrate<'a> {
127
128
pub readme : Option < & ' a str > ,
128
129
pub repository : Option < & ' a str > ,
129
130
pub max_upload_size : Option < i32 > ,
131
+ pub license : Option < & ' a str > ,
130
132
}
131
133
132
134
impl < ' a > NewCrate < ' a > {
133
135
pub fn create_or_update (
134
- self ,
136
+ mut self ,
135
137
conn : & PgConnection ,
136
138
license_file : Option < & str > ,
137
139
uploader : i32 ,
138
140
) -> CargoResult < Crate > {
139
141
use diesel:: update;
140
142
141
- self . validate ( ) ?;
143
+ self . validate ( license_file ) ?;
142
144
self . ensure_name_not_reserved ( conn) ?;
143
145
144
146
conn. transaction ( || {
@@ -159,7 +161,7 @@ impl<'a> NewCrate<'a> {
159
161
} )
160
162
}
161
163
162
- fn validate ( & self ) -> CargoResult < ( ) > {
164
+ fn validate ( & mut self , license_file : Option < & str > ) -> CargoResult < ( ) > {
163
165
fn validate_url ( url : Option < & str > , field : & str ) -> CargoResult < ( ) > {
164
166
let url = match url {
165
167
Some ( s) => s,
@@ -501,6 +503,7 @@ impl Crate {
501
503
description,
502
504
homepage,
503
505
documentation,
506
+ license,
504
507
repository,
505
508
..
506
509
} = self ;
@@ -526,6 +529,7 @@ impl Crate {
526
529
homepage : homepage,
527
530
exact_match : exact_match,
528
531
description : description,
532
+ license : license,
529
533
repository : repository,
530
534
links : CrateLinks {
531
535
version_downloads : format ! ( "/api/v1/crates/{}/downloads" , name) ,
0 commit comments