Skip to content

Commit

Permalink
fix: remove bucket creation in s3 persister
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre committed Oct 9, 2024
1 parent aa1ca4e commit fb8874a
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions server/src/persistence/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,6 @@ impl From<SdkError<PutObjectError>> for EdgeError {
}
}

impl S3Persister {
async fn create_bucket_if_not_exists(&self) -> EdgeResult<()> {
match self
.client
.create_bucket()
.bucket(&self.bucket)
.send()
.await
{
Ok(_) => Ok(()),
Err(err) => {
if err.to_string().contains("BucketAlreadyOwnedByYou")
|| err.to_string().contains("BucketAlreadyExists")
{
Ok(())
} else {
Err(EdgeError::PersistenceError(format!(
"Failed to create bucket: {}",
err
)))
}
}
}
}
}

#[async_trait]
impl EdgePersistence for S3Persister {
async fn load_tokens(&self) -> EdgeResult<Vec<EdgeToken>> {
Expand All @@ -96,7 +70,6 @@ impl EdgePersistence for S3Persister {
}

async fn save_tokens(&self, tokens: Vec<EdgeToken>) -> EdgeResult<()> {
self.create_bucket_if_not_exists().await?;
let body_data = serde_json::to_vec(&tokens)
.map_err(|_| EdgeError::PersistenceError("Failed to serialize tokens".to_string()))
.map(SdkBody::from)?;
Expand Down Expand Up @@ -144,7 +117,6 @@ impl EdgePersistence for S3Persister {
}

async fn save_features(&self, features: Vec<(String, ClientFeatures)>) -> EdgeResult<()> {
self.create_bucket_if_not_exists().await?;
let body_data = serde_json::to_vec(&features)
.map_err(|_| EdgeError::PersistenceError("Failed to serialize features".to_string()))?;
let byte_stream = ByteStream::new(SdkBody::from(body_data));
Expand Down

0 comments on commit fb8874a

Please sign in to comment.