From aec4411be8053dd6123c0b45d9b73f4792bc42ef Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 4 Nov 2025 07:07:39 -0300 Subject: [PATCH] feat: check bucket existence before uploading templates Only upload templates to Drive buckets if the bucket was just created. Skip upload if bucket already exists to avoid overwriting existing content. - Change from always uploading to conditionally uploading based on bucket existence - Add info log when skipping upload for existing buckets - Maintain same upload behavior for newly created buckets --- src/bootstrap/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/mod.rs b/src/bootstrap/mod.rs index 35b43115..39a74f5a 100644 --- a/src/bootstrap/mod.rs +++ b/src/bootstrap/mod.rs @@ -365,17 +365,21 @@ impl BootstrapManager { { let bot_name = path.file_name().unwrap().to_string_lossy().to_string(); let bucket = bot_name.trim_start_matches('/').to_string(); - info!("Uploading template {} to Drive bucket {}", bot_name, bucket); + info!("Checking template {} for Drive bucket {}", bot_name, bucket); // Check if bucket exists if client.head_bucket().bucket(&bucket).send().await.is_err() { - info!("Bucket {} not found, creating it", bucket); + info!("Bucket {} not found, creating it and uploading template", bucket); match client.create_bucket() .bucket(&bucket) .send() .await { Ok(_) => { debug!("Bucket {} created successfully", bucket); + // Only upload template if bucket was just created + self.upload_directory_recursive(client, &path, &bucket, "/") + .await?; + info!("Uploaded template {} to Drive bucket {}", bot_name, bucket); } Err(e) => { error!("Failed to create bucket {}: {:?}", bucket, e); @@ -385,11 +389,9 @@ impl BootstrapManager { )); } } + } else { + info!("Bucket {} already exists, skipping template upload", bucket); } - - self.upload_directory_recursive(client, &path, &bucket, "/") - .await?; - info!("Uploaded template {} to Drive bucket {}", bot_name, bucket); } } Ok(())