Fix integration with backblaze API (#461)

* Fix integration with backblaze API

* Remove keys (already reset, dw)
This commit is contained in:
Geometrically 2022-10-09 19:10:06 -07:00 committed by GitHub
parent 3e52f804a7
commit 07edb998e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 37 deletions

2
.env
View File

@ -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

View File

@ -46,8 +46,6 @@ impl S3Host {
)
})?;
bucket.add_header("x-amz-acl", "public-read");
Ok(S3Host { bucket })
}
}

View File

@ -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?;

View File

@ -360,12 +360,10 @@ 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?;
}
if let Some(icon_path) = name {
file_host.delete_file_version("", icon_path).await?;
}
}

View File

@ -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(""))

View File

@ -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(""))