Skip to content

Commit

Permalink
object_store: Adjust to API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Nov 6, 2023
1 parent 13ff223 commit df6dc8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,27 @@ impl Storage {
#[instrument(skip(self, bytes))]
pub async fn upload_crate_file(&self, name: &str, version: &str, bytes: Bytes) -> Result<()> {
let path = crate_file_path(name, version);
self.crate_upload_store.put(&path, bytes).await
self.crate_upload_store.put(&path, bytes).await?;
Ok(())
}

#[instrument(skip(self, bytes))]
pub async fn upload_readme(&self, name: &str, version: &str, bytes: Bytes) -> Result<()> {
let path = readme_path(name, version);
self.readme_upload_store.put(&path, bytes).await
self.readme_upload_store.put(&path, bytes).await?;
Ok(())
}

#[instrument(skip(self, content))]
pub async fn sync_index(&self, name: &str, content: Option<String>) -> Result<()> {
let path = crates_io_index::Repository::relative_index_file_for_url(name).into();
if let Some(content) = content {
self.index_upload_store.put(&path, content.into()).await
self.index_upload_store.put(&path, content.into()).await?;
} else {
self.index_store.delete(&path).await
self.index_store.delete(&path).await?;
}

Ok(())
}

#[instrument(skip(self))]
Expand Down Expand Up @@ -302,7 +306,7 @@ impl Storage {
}

async fn delete_all_with_prefix(&self, prefix: &Path) -> Result<()> {
let objects = self.store.list(Some(prefix)).await?;
let objects = self.store.list(Some(prefix));
let locations = objects.map(|meta| meta.map(|m| m.location)).boxed();

self.store
Expand Down Expand Up @@ -378,7 +382,7 @@ mod tests {
}

pub async fn stored_files(store: &dyn ObjectStore) -> Vec<String> {
let stream = store.list(None).await.unwrap();
let stream = store.list(None);
let list = stream.try_collect::<Vec<_>>().await.unwrap();

list.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/tests/util/test_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl TestApp {
.unwrap();

let list = rt.block_on(async {
let stream = store.list(None).await.unwrap();
let stream = store.list(None);
stream.try_collect::<Vec<_>>().await.unwrap()
});

Expand Down

0 comments on commit df6dc8e

Please sign in to comment.