Skip to content

Commit d05b8c5

Browse files
committed
chore: expose file IDs in version queries
1 parent a16bd78 commit d05b8c5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

apps/labrinth/src/models/v3/projects.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ impl From<VersionQueryResult> for Version {
716716
.files
717717
.into_iter()
718718
.map(|f| VersionFile {
719+
id: Some(f.id.0),
719720
url: f.url,
720721
filename: f.filename,
721722
hashes: f.hashes,
@@ -840,6 +841,10 @@ impl VersionStatus {
840841
/// A single project file, with a url for the file and the file's hash
841842
#[derive(Serialize, Deserialize, Clone)]
842843
pub struct VersionFile {
844+
/// The ID of the file. Every file has an ID once created, but it
845+
/// is not known until it indeed has been created.
846+
#[serde(default, skip_serializing_if = "Option::is_none")]
847+
pub id: Option<i64>,
843848
/// A map of hashes of the file. The key is the hashing algorithm
844849
/// and the value is the string version of the hash.
845850
pub hashes: std::collections::HashMap<String, String>,

apps/labrinth/src/routes/v3/version_creation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ async fn version_create_inner(
447447
.files
448448
.iter()
449449
.map(|file| VersionFile {
450+
id: None,
450451
hashes: file
451452
.hashes
452453
.iter()

0 commit comments

Comments
 (0)