Skip to content

Commit 61f5a2f

Browse files
committed
publish: Save edition field from published Cargo.toml file in the database
1 parent e24f72c commit 61f5a2f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/controllers/krate/publish.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
162162
let documentation = package.documentation.map(|it| it.as_local().unwrap());
163163
let repository = package.repository.map(|it| it.as_local().unwrap());
164164
let rust_version = package.rust_version.map(|rv| rv.as_local().unwrap());
165+
let edition = package.edition.map(|rv| rv.as_local().unwrap());
165166

166167
// Make sure required fields are provided
167168
fn empty(s: Option<&String>) -> bool {
@@ -365,6 +366,8 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
365366
.filter_map(|bin| bin.name.as_deref())
366367
.collect::<Vec<_>>();
367368

369+
let edition = edition.map(|edition| edition.as_str());
370+
368371
// Read tarball from request
369372
let hex_cksum: String = Sha256::digest(&tarball_bytes).encode_hex();
370373

@@ -381,6 +384,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
381384
.maybe_rust_version(rust_version.as_deref())
382385
.has_lib(tarball_info.manifest.lib.is_some())
383386
.bin_names(bin_names.as_slice())
387+
.maybe_edition(edition)
384388
.build();
385389

386390
let version = new_version.save(conn, &verified_email_address).map_err(|error| {

src/models/version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub struct NewVersion<'a> {
9797
rust_version: Option<&'a str>,
9898
pub has_lib: Option<bool>,
9999
pub bin_names: Option<&'a [&'a str]>,
100+
edition: Option<&'a str>,
100101
}
101102

102103
impl NewVersion<'_> {

0 commit comments

Comments
 (0)