Skip to content

Commit 4c3e294

Browse files
authored
Fix unnecessary downloads of cached registry packages (#1571)
Closes #1544
1 parent dd76848 commit 4c3e294

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

scarb/src/core/registry/client/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'c> RegistryClientCache<'c> {
145145
let tarball_name = package.tarball_name();
146146
let file = self
147147
.dl_fs
148-
.open_rw(&tarball_name, &tarball_name, self.config)?;
148+
.open_ro(&tarball_name, &tarball_name, self.config)?;
149149
let checksum = self.get_record_maybe_uncached(package).await?.checksum;
150150
return Ok((file, checksum));
151151
}

scarb/tests/http_registry.rs

+22
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ fn caching() {
309309
.success()
310310
.stdout_eq("");
311311

312+
Scarb::quick_snapbox()
313+
.arg("fetch")
314+
.env("SCARB_CACHE", cache_dir.path())
315+
.current_dir(&t)
316+
.timeout(Duration::from_secs(10))
317+
.assert()
318+
.success()
319+
.stdout_eq("");
320+
312321
let expected = expect![[r#"
313322
GET /api/v1/index/config.json
314323
accept: */*
@@ -365,6 +374,19 @@ fn caching() {
365374
304 Not Modified
366375
content-length: 0
367376
etag: ...
377+
378+
###
379+
380+
GET /index/3/b/bar.json
381+
accept: */*
382+
accept-encoding: gzip, br, deflate
383+
host: ...
384+
if-none-match: ...
385+
user-agent: ...
386+
387+
304 Not Modified
388+
content-length: 0
389+
etag: ...
368390
"#]];
369391
expected.assert_eq(&registry.logs());
370392
}

0 commit comments

Comments
 (0)