Skip to content

Commit

Permalink
Fix unnecessary downloads of cached registry packages (#1571)
Browse files Browse the repository at this point in the history
Closes #1544
  • Loading branch information
DelevoXDG authored Sep 3, 2024
1 parent dd76848 commit 4c3e294
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scarb/src/core/registry/client/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'c> RegistryClientCache<'c> {
let tarball_name = package.tarball_name();
let file = self
.dl_fs
.open_rw(&tarball_name, &tarball_name, self.config)?;
.open_ro(&tarball_name, &tarball_name, self.config)?;
let checksum = self.get_record_maybe_uncached(package).await?.checksum;
return Ok((file, checksum));
}
Expand Down
22 changes: 22 additions & 0 deletions scarb/tests/http_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ fn caching() {
.success()
.stdout_eq("");

Scarb::quick_snapbox()
.arg("fetch")
.env("SCARB_CACHE", cache_dir.path())
.current_dir(&t)
.timeout(Duration::from_secs(10))
.assert()
.success()
.stdout_eq("");

let expected = expect![[r#"
GET /api/v1/index/config.json
accept: */*
Expand Down Expand Up @@ -365,6 +374,19 @@ fn caching() {
304 Not Modified
content-length: 0
etag: ...
###
GET /index/3/b/bar.json
accept: */*
accept-encoding: gzip, br, deflate
host: ...
if-none-match: ...
user-agent: ...
304 Not Modified
content-length: 0
etag: ...
"#]];
expected.assert_eq(&registry.logs());
}
Expand Down

0 comments on commit 4c3e294

Please sign in to comment.