Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lock when indexing #1030

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/rattler_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ license.workspace = true
readme.workspace = true

[dependencies]
anyhow = { workspace = true }
fs-err = { workspace = true }
libc = { workspace = true }
rattler_conda_types = { path="../rattler_conda_types", version = "0.29.10", default-features = false }
rattler_digest = { path="../rattler_digest", version = "1.0.5", default-features = false }
rattler_package_streaming = { path="../rattler_package_streaming", version = "0.22.23", default-features = false }
Expand Down
6 changes: 6 additions & 0 deletions crates/rattler_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! files
#![deny(missing_docs)]

mod locked_file;
use std::{
collections::{HashMap, HashSet},
ffi::OsStr,
Expand Down Expand Up @@ -202,7 +203,12 @@ pub fn index(
.insert(file_name.to_string_lossy().to_string(), record),
};
}

let out_file = output_folder.join(platform).join("repodata.json");

// Lock all files that have to do with that cache key
let lock_file_path = output_folder.join("repodata.json.lock");
let _lock_file = locked_file::LockedFile::open_rw(lock_file_path, "repodata cache");
File::create(&out_file)?.write_all(serde_json::to_string_pretty(&repodata)?.as_bytes())?;
}

Expand Down
Loading
Loading