Fix integration with backblaze API (#461)
* Fix integration with backblaze API * Remove keys (already reset, dw)
This commit is contained in:
parent
3e52f804a7
commit
07edb998e4
2
.env
2
.env
@ -2,7 +2,7 @@ DEBUG=true
|
||||
RUST_LOG=info,sqlx::query=warn
|
||||
|
||||
SITE_URL=https://modrinth.com
|
||||
CDN_URL=https://cdn.modrinth.com
|
||||
CDN_URL=https://staging-cdn.modrinth.com
|
||||
LABRINTH_ADMIN_KEY=feedbeef
|
||||
RATE_LIMIT_IGNORE_KEY=feedbeef
|
||||
|
||||
|
||||
@ -46,8 +46,6 @@ impl S3Host {
|
||||
)
|
||||
})?;
|
||||
|
||||
bucket.add_header("x-amz-acl", "public-read");
|
||||
|
||||
Ok(S3Host { bucket })
|
||||
}
|
||||
}
|
||||
|
||||
@ -1046,7 +1046,7 @@ pub async fn project_icon_edit(
|
||||
}
|
||||
|
||||
if let Some(icon) = project_item.icon_url {
|
||||
let name = icon.split('/').next();
|
||||
let name = icon.split(&format!("{cdn_url}/")).nth(1);
|
||||
|
||||
if let Some(icon_path) = name {
|
||||
file_host.delete_file_version("", icon_path).await?;
|
||||
@ -1136,8 +1136,9 @@ pub async fn delete_project_icon(
|
||||
}
|
||||
}
|
||||
|
||||
let cdn_url = dotenv::var("CDN_URL")?;
|
||||
if let Some(icon) = project_item.icon_url {
|
||||
let name = icon.split('/').next();
|
||||
let name = icon.split(&format!("{cdn_url}/")).nth(1);
|
||||
|
||||
if let Some(icon_path) = name {
|
||||
file_host.delete_file_version("", icon_path).await?;
|
||||
@ -1489,10 +1490,11 @@ pub async fn delete_gallery_item(
|
||||
})?
|
||||
.id;
|
||||
|
||||
let name = item.url.split('/').next();
|
||||
let cdn_url = dotenv::var("CDN_URL")?;
|
||||
let name = item.url.split(&format!("{cdn_url}/")).nth(1);
|
||||
|
||||
if let Some(item_path) = name {
|
||||
file_host.delete_file_version("", item_path).await?;
|
||||
if let Some(icon_path) = name {
|
||||
file_host.delete_file_version("", icon_path).await?;
|
||||
}
|
||||
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
@ -360,14 +360,12 @@ pub async fn user_icon_edit(
|
||||
}
|
||||
|
||||
if let Some(icon) = icon_url {
|
||||
if icon.starts_with(&cdn_url) {
|
||||
let name = icon.split('/').next();
|
||||
let name = icon.split(&format!("{cdn_url}/")).nth(1);
|
||||
|
||||
if let Some(icon_path) = name {
|
||||
file_host.delete_file_version("", icon_path).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let bytes = read_from_payload(
|
||||
&mut payload,
|
||||
|
||||
@ -357,18 +357,6 @@ pub async fn delete_file(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
let project_id: models::projects::ProjectId =
|
||||
database::models::ids::ProjectId(row.project_id).into();
|
||||
file_host
|
||||
.delete_file_version(
|
||||
"",
|
||||
&format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id, row.version_number, row.filename
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(HttpResponse::NoContent().body(""))
|
||||
|
||||
@ -206,18 +206,6 @@ pub async fn delete_file(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
let project_id: models::projects::ProjectId =
|
||||
database::models::ids::ProjectId(row.project_id).into();
|
||||
file_host
|
||||
.delete_file_version(
|
||||
"",
|
||||
&format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id, row.version_number, row.filename
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(HttpResponse::NoContent().body(""))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user