Skip to content

Commit 560a6e0

Browse files
committed
Address PR comments
1 parent c807076 commit 560a6e0

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

apps/labrinth/src/file_hosting/mock.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ impl FileHost for MockHost {
2727
file_publicity: FileHostPublicity,
2828
file_bytes: Bytes,
2929
) -> Result<UploadFileData, FileHostingError> {
30-
let path = get_file_path(file_name, file_publicity);
30+
let file_name = urlencoding::decode(file_name)
31+
.map_err(|_| FileHostingError::InvalidFilename)?;
32+
let path = get_file_path(&file_name, file_publicity);
3133
std::fs::create_dir_all(
3234
path.parent().ok_or(FileHostingError::InvalidFilename)?,
3335
)?;

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,10 @@ pub async fn run(
249249
run_parameters.file_id.0
250250
);
251251

252-
// fix for local file paths
253-
// TODO: should we fix this upstream in whatever inserts the files row?
254-
let url = if file_data.url.starts_with("/") {
255-
format!("file://{}", file_data.url)
256-
} else {
257-
file_data.url
258-
};
259-
260252
DELPHI_CLIENT
261253
.post(dotenvy::var("DELPHI_URL")?)
262254
.json(&serde_json::json!({
263-
"url": url,
255+
"url": file_data.url,
264256
"project_id": ProjectId(file_data.project_id.0 as u64),
265257
"version_id": VersionId(file_data.version_id.0 as u64),
266258
"file_id": run_parameters.file_id,

apps/labrinth/src/routes/internal/moderation/tech_review.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pub struct FileReport {
113113
pub file_name: String,
114114
/// Size of the flagged file, in bytes.
115115
pub file_size: i32,
116+
/// URL to download the flagged file.
117+
pub download_url: String,
116118
/// What issues appeared in the file.
117119
pub issues: Vec<FileIssue>,
118120
}
@@ -239,6 +241,7 @@ async fn get_report(
239241
'file_name', f.filename,
240242
'file_size', f.size,
241243
'flag_reason', 'delphi',
244+
'download_url', f.url,
242245
'issues', json_array(
243246
SELECT
244247
to_jsonb(dri)
@@ -352,6 +355,7 @@ async fn search_projects(
352355
'file_name', f.filename,
353356
'file_size', f.size,
354357
'flag_reason', 'delphi',
358+
'download_url', f.url,
355359
'issues', json_array(
356360
SELECT
357361
to_jsonb(dri)

0 commit comments

Comments
 (0)