fix: use regular if bucket is empty

This commit is contained in:
trisua 2025-08-23 14:52:14 -04:00
parent 71a89e6c44
commit 4e4f26ea14
3 changed files with 11 additions and 4 deletions

2
Cargo.lock generated
View file

@ -250,7 +250,7 @@ dependencies = [
[[package]]
name = "buckets-core"
version = "1.0.2"
version = "1.0.3"
dependencies = [
"oiseau",
"pathbufd",

View file

@ -1,7 +1,7 @@
[package]
name = "buckets-core"
description = "Buckets media upload types"
version = "1.0.2"
version = "1.0.3"
edition = "2024"
readme = "../../README.md"
authors.workspace = true

View file

@ -21,7 +21,11 @@ impl DataManager {
auto_method!(get_upload_by_id(usize as i64)@get_upload_from_row -> "SELECT * FROM uploads WHERE id = $1" --name="upload" --returns=MediaUpload --cache-key-tmpl="atto.upload:{}");
/// Get an upload by its ID and bucket.
pub async fn get_upload_by_id_bucket(&self, id: usize, bucket: String) -> Result<MediaUpload> {
pub async fn get_upload_by_id_bucket(&self, id: usize, bucket: &str) -> Result<MediaUpload> {
if bucket.is_empty() {
return self.get_upload_by_id(id).await;
}
let conn = match self.0.connect().await {
Ok(c) => c,
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
@ -193,10 +197,13 @@ impl DataManager {
}
/// Delete an upload given its `id` and `bucket`.
pub async fn delete_upload_with_bucket(&self, id: usize, bucket: String) -> Result<()> {
pub async fn delete_upload_with_bucket(&self, id: usize, bucket: &str) -> Result<()> {
// if !user.permissions.check(FinePermission::MANAGE_UPLOADS) {
// return Err(Error::NotAllowed);
// }
if bucket.is_empty() {
return self.delete_upload(id).await;
}
// delete file
// it's most important that the file gets off the file system first, even