Skip to content

Commit

Permalink
client: Fix Client::update on empty registry storage
Browse files Browse the repository at this point in the history
  • Loading branch information
lann committed Jul 24, 2023
1 parent 1cbd8d5 commit b6f0f40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/client/src/storage/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ impl RegistryStorage for FileSystemRegistryStorage {
let mut packages = Vec::new();

let packages_dir = self.base_dir.join(PACKAGE_LOGS_DIR);
if !packages_dir.exists() {
return Ok(vec![]);
}

for entry in WalkDir::new(&packages_dir) {
let entry = entry.with_context(|| {
anyhow!(
Expand Down
3 changes: 3 additions & 0 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ async fn client_incrementally_fetches() -> Result<()> {
// Recreate the client with the same config
let client = create_client(&config)?;

// Regression test: update on empty registry storage
client.update().await?;

// Fetch the package log
client.upsert([&id]).await?;

Expand Down

0 comments on commit b6f0f40

Please sign in to comment.