Skip to content

Commit 352a5dc

Browse files
committed
tweak(labrinth): expose base62 file IDs more consistently for Delphi
1 parent b36e08e commit 352a5dc

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

apps/labrinth/src/database/models/version_item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ impl VersionFileBuilder {
167167

168168
if let Err(err) = crate::routes::internal::delphi::run(
169169
&mut **transaction,
170-
DelphiRunParameters { file_id },
170+
DelphiRunParameters {
171+
file_id: file_id.into(),
172+
},
171173
)
172174
.await
173175
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::database::models::loader_fields::VersionField;
55
use crate::database::models::project_item::{LinkUrl, ProjectQueryResult};
66
use crate::database::models::version_item::VersionQueryResult;
77
use crate::models::ids::{
8-
OrganizationId, ProjectId, TeamId, ThreadId, VersionId,
8+
FileId, OrganizationId, ProjectId, TeamId, ThreadId, VersionId,
99
};
1010
use ariadne::ids::UserId;
1111
use chrono::{DateTime, Utc};
@@ -716,7 +716,7 @@ impl From<VersionQueryResult> for Version {
716716
.files
717717
.into_iter()
718718
.map(|f| VersionFile {
719-
id: Some(f.id.0),
719+
id: Some(FileId(f.id.0 as u64)),
720720
url: f.url,
721721
filename: f.filename,
722722
hashes: f.hashes,
@@ -844,7 +844,7 @@ pub struct VersionFile {
844844
/// The ID of the file. Every file has an ID once created, but it
845845
/// is not known until it indeed has been created.
846846
#[serde(default, skip_serializing_if = "Option::is_none")]
847-
pub id: Option<i64>,
847+
pub id: Option<FileId>,
848848
/// A map of hashes of the file. The key is the hashing algorithm
849849
/// and the value is the string version of the hash.
850850
pub hashes: std::collections::HashMap<String, String>,

apps/labrinth/src/routes/internal/delphi.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ use crate::{
2121
},
2222
redis::RedisPool,
2323
},
24-
models::pats::Scopes,
24+
models::{
25+
ids::{ProjectId, VersionId},
26+
pats::Scopes,
27+
},
2528
queue::session::AuthQueue,
2629
routes::ApiError,
2730
util::guards::admin_key_guard,
@@ -90,7 +93,7 @@ impl DelphiReport {
9093

9194
#[derive(Deserialize)]
9295
pub struct DelphiRunParameters {
93-
pub file_id: crate::database::models::ids::DBFileId,
96+
pub file_id: crate::models::ids::FileId,
9497
}
9598

9699
#[post("ingest", guard = "admin_key_guard")]
@@ -158,7 +161,7 @@ pub async fn run(
158161
FROM files INNER JOIN versions ON files.version_id = versions.id
159162
WHERE files.id = $1
160163
"#,
161-
run_parameters.file_id.0
164+
run_parameters.file_id.0 as i64
162165
)
163166
.fetch_one(exec)
164167
.await?;
@@ -177,8 +180,8 @@ pub async fn run(
177180
.post(dotenvy::var("DELPHI_URL")?)
178181
.json(&serde_json::json!({
179182
"url": file_data.url,
180-
"project_id": file_data.project_id,
181-
"version_id": file_data.version_id,
183+
"project_id": ProjectId(file_data.project_id.0 as u64),
184+
"version_id": VersionId(file_data.version_id.0 as u64),
182185
"file_id": run_parameters.file_id,
183186
}))
184187
.send()

0 commit comments

Comments
 (0)