Skip to content

Commit 7b1393a

Browse files
committed
nix-index: don't write to cache if we read from it
this makes it possible to use a read-only cache (e.g. from `/nix/store`)
1 parent 0fc3804 commit 7b1393a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bin/nix-index.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async fn update_index(args: &Args) -> Result<()> {
2828
} else {
2929
None
3030
};
31+
let using_cache = cached.is_some();
3132

3233
eprintln!("+ querying available packages");
3334
let fetcher = Fetcher::new(CACHE_URL.to_string()).map_err(Error::ParseProxy)?;
@@ -101,7 +102,7 @@ async fn update_index(args: &Args) -> Result<()> {
101102
}
102103
eprintln!();
103104

104-
if args.path_cache {
105+
if args.path_cache && !using_cache {
105106
eprintln!("+ writing path cache");
106107
let mut output = io::BufWriter::new(File::create("paths.cache").map_err(|e| {
107108
Error::WritePathsCache {

0 commit comments

Comments
 (0)