Skip to content

Commit

Permalink
Fix: Add indexed packages to the relevant section in the repodata (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhany97 authored Feb 15, 2024
1 parent ea36f12 commit 80532f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
11 changes: 8 additions & 3 deletions crates/rattler_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,14 @@ pub fn index(
tracing::info!("Could not read package record from {:?}", p);
continue;
};
repodata
.conda_packages
.insert(file_name.to_string_lossy().to_string(), record);
match t {
ArchiveType::TarBz2 => repodata
.packages
.insert(file_name.to_string_lossy().to_string(), record),
ArchiveType::Conda => repodata
.conda_packages
.insert(file_name.to_string_lossy().to_string(), record),
};
}
let out_file = output_folder.join(platform).join("repodata.json");
File::create(&out_file)?.write_all(serde_json::to_string_pretty(&repodata)?.as_bytes())?;
Expand Down
19 changes: 15 additions & 4 deletions crates/rattler_index/tests/test_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ fn test_data_dir() -> PathBuf {
fn test_index() {
let temp_dir = tempfile::tempdir().unwrap();
let subdir_path = Path::new("win-64");
let file_path = Path::new("conda-22.11.1-py38haa244fe_1.conda");
let conda_file_path = Path::new("conda-22.11.1-py38haa244fe_1.conda");
let index_json_path = Path::new("conda-22.11.1-py38haa244fe_1-index.json");
let tar_bz2_file_path = Path::new("conda-22.9.0-py38haa244fe_2.tar.bz2");

fs::create_dir(temp_dir.path().join(subdir_path)).unwrap();
fs::copy(
test_data_dir().join(file_path),
temp_dir.path().join(subdir_path).join(file_path),
test_data_dir().join(conda_file_path),
temp_dir.path().join(subdir_path).join(conda_file_path),
)
.unwrap();
fs::copy(
test_data_dir().join(tar_bz2_file_path),
temp_dir.path().join(subdir_path).join(tar_bz2_file_path),
)
.unwrap();

Expand All @@ -41,7 +48,11 @@ fn test_index() {
.as_str(),
Some("win-64")
);
assert!(repodata_json.get("packages").is_some());
assert!(repodata_json
.get("packages")
.unwrap()
.get("conda-22.9.0-py38haa244fe_2.tar.bz2")
.is_some());
assert_eq!(
repodata_json
.get("packages.conda")
Expand Down

0 comments on commit 80532f2

Please sign in to comment.