Skip to content

Commit 98d5992

Browse files
committed
Adds concrete functions to initialize the LRU
1 parent 073ada9 commit 98d5992

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pnp"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition = "2021"
55
license = "BSD-2-Clause"
66
description = "Resolution primitives for Yarn PnP"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use pnp::fs::{VPath, LruZipCache, open_zip_via_read};
9797

9898
const ZIP_CACHE: Lazy<LruZipCache<Vec<u8>>> = Lazy::new(|| {
9999
// It'll keep the last 50 zip archives open
100-
LruZipCache::new(50, open_zip_via_read)
100+
LruZipCache::new(50, open_zip_via_read_p)
101101
});
102102

103103
fn read_file(p: PathBuf) -> std::io::Result<String> {

src/fs.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ pub fn open_zip_via_mmap<P: AsRef<Path>>(p: P) -> Result<Zip<mmap_rs::Mmap>, std
8484

8585
Ok(zip)
8686
}
87+
88+
#[cfg(feature = "mmap")]
89+
pub fn open_zip_via_mmap_p(p: &Path) -> Result<Zip<mmap_rs::Mmap>, std::io::Error> {
90+
open_zip_via_mmap(p)
91+
}
92+
8793
pub fn open_zip_via_read<P: AsRef<Path>>(p: P) -> Result<Zip<Vec<u8>>, std::io::Error> {
8894
let data = std::fs::read(p)?;
8995

@@ -93,6 +99,10 @@ pub fn open_zip_via_read<P: AsRef<Path>>(p: P) -> Result<Zip<Vec<u8>>, std::io::
9399
Ok(zip)
94100
}
95101

102+
pub fn open_zip_via_read_p(p: &Path) -> Result<Zip<Vec<u8>>, std::io::Error> {
103+
open_zip_via_read(p)
104+
}
105+
96106
pub trait ZipCache<Storage>
97107
where Storage: AsRef<[u8]> + Send + Sync {
98108
fn act<T, P: AsRef<Path>, F : FnOnce(&Zip<Storage>) -> T>(&self, p: P, cb: F) -> Result<T, std::io::Error>;

0 commit comments

Comments
 (0)