@@ -122,6 +122,9 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
122
122
let description = package. description . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
123
123
let mut license = package. license . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
124
124
let license_file = package. license_file . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
125
+ let homepage = package. homepage . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
126
+ let documentation = package. documentation . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
127
+ let repository = package. repository . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
125
128
126
129
// Make sure required fields are provided
127
130
fn empty ( s : Option < & String > ) -> bool {
@@ -150,13 +153,16 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
150
153
license = Some ( String :: from ( "non-standard" ) ) ;
151
154
}
152
155
156
+ validate_url ( homepage. as_deref ( ) , "homepage" ) ?;
157
+ validate_url ( documentation. as_deref ( ) , "documentation" ) ?;
158
+ validate_url ( repository. as_deref ( ) , "repository" ) ?;
159
+
153
160
// Create a transaction on the database, if there are no errors,
154
161
// commit the transactions to record a new or updated crate.
155
162
conn. transaction ( |conn| {
156
163
let name = metadata. name ;
157
164
let vers = & * metadata. vers ;
158
165
let links = metadata. links ;
159
- let repo = metadata. repository ;
160
166
let features = metadata
161
167
. features
162
168
. into_iter ( )
@@ -177,17 +183,13 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
177
183
let persist = NewCrate {
178
184
name : & name,
179
185
description : description. as_deref ( ) ,
180
- homepage : metadata . homepage . as_deref ( ) ,
181
- documentation : metadata . documentation . as_deref ( ) ,
186
+ homepage : homepage. as_deref ( ) ,
187
+ documentation : documentation. as_deref ( ) ,
182
188
readme : metadata. readme . as_deref ( ) ,
183
- repository : repo . as_deref ( ) ,
189
+ repository : repository . as_deref ( ) ,
184
190
max_upload_size : None ,
185
191
} ;
186
192
187
- validate_url ( persist. homepage , "homepage" ) ?;
188
- validate_url ( persist. documentation , "documentation" ) ?;
189
- validate_url ( persist. repository , "repository" ) ?;
190
-
191
193
if is_reserved_name ( persist. name , conn) ? {
192
194
return Err ( cargo_err ( "cannot upload a crate with a reserved name" ) ) ;
193
195
}
@@ -271,7 +273,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
271
273
metadata
272
274
. readme_file
273
275
. unwrap_or_else ( || String :: from ( "README.md" ) ) ,
274
- repo ,
276
+ repository ,
275
277
pkg_path_in_vcs,
276
278
)
277
279
. enqueue_with_priority ( conn, PRIORITY_RENDER_README ) ?;
0 commit comments