Skip to content

Commit a2cce68

Browse files
committed
chore: expose file IDs in version queries
1 parent 220b2a0 commit a2cce68

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
@@ -712,6 +712,7 @@ impl From<VersionQueryResult> for Version {
712712
.files
713713
.into_iter()
714714
.map(|f| VersionFile {
715+
id: Some(f.id.0),
715716
url: f.url,
716717
filename: f.filename,
717718
hashes: f.hashes,
@@ -836,6 +837,10 @@ impl VersionStatus {
836837
/// A single project file, with a url for the file and the file's hash
837838
#[derive(Serialize, Deserialize, Clone)]
838839
pub struct VersionFile {
840+
/// The ID of the file. Every file has an ID once created, but it
841+
/// is not known until it indeed has been created.
842+
#[serde(default, skip_serializing_if = "Option::is_none")]
843+
pub id: Option<i64>,
839844
/// A map of hashes of the file. The key is the hashing algorithm
840845
/// and the value is the string version of the hash.
841846
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
@@ -446,6 +446,7 @@ async fn version_create_inner(
446446
.files
447447
.iter()
448448
.map(|file| VersionFile {
449+
id: None,
449450
hashes: file
450451
.hashes
451452
.iter()

0 commit comments

Comments
 (0)