From 4e4f26ea1409758de9be3092cb4e8855724b8c6a Mon Sep 17 00:00:00 2001 From: trisua Date: Sat, 23 Aug 2025 14:52:14 -0400 Subject: [PATCH] fix: use regular if bucket is empty --- Cargo.lock | 2 +- crates/buckets-core/Cargo.toml | 2 +- crates/buckets-core/src/database/uploads.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c8ac0d..c455c55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,7 +250,7 @@ dependencies = [ [[package]] name = "buckets-core" -version = "1.0.2" +version = "1.0.3" dependencies = [ "oiseau", "pathbufd", diff --git a/crates/buckets-core/Cargo.toml b/crates/buckets-core/Cargo.toml index 306bc07..bbe715d 100644 --- a/crates/buckets-core/Cargo.toml +++ b/crates/buckets-core/Cargo.toml @@ -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 diff --git a/crates/buckets-core/src/database/uploads.rs b/crates/buckets-core/src/database/uploads.rs index 7158618..5b51a33 100644 --- a/crates/buckets-core/src/database/uploads.rs +++ b/crates/buckets-core/src/database/uploads.rs @@ -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 { + pub async fn get_upload_by_id_bucket(&self, id: usize, bucket: &str) -> Result { + 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