Skip to content

Commit 80532f2

Browse files
authored
Fix: Add indexed packages to the relevant section in the repodata (#529)
1 parent ea36f12 commit 80532f2

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

crates/rattler_index/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,14 @@ pub fn index(
178178
tracing::info!("Could not read package record from {:?}", p);
179179
continue;
180180
};
181-
repodata
182-
.conda_packages
183-
.insert(file_name.to_string_lossy().to_string(), record);
181+
match t {
182+
ArchiveType::TarBz2 => repodata
183+
.packages
184+
.insert(file_name.to_string_lossy().to_string(), record),
185+
ArchiveType::Conda => repodata
186+
.conda_packages
187+
.insert(file_name.to_string_lossy().to_string(), record),
188+
};
184189
}
185190
let out_file = output_folder.join(platform).join("repodata.json");
186191
File::create(&out_file)?.write_all(serde_json::to_string_pretty(&repodata)?.as_bytes())?;

crates/rattler_index/tests/test_index.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@ fn test_data_dir() -> PathBuf {
1313
fn test_index() {
1414
let temp_dir = tempfile::tempdir().unwrap();
1515
let subdir_path = Path::new("win-64");
16-
let file_path = Path::new("conda-22.11.1-py38haa244fe_1.conda");
16+
let conda_file_path = Path::new("conda-22.11.1-py38haa244fe_1.conda");
1717
let index_json_path = Path::new("conda-22.11.1-py38haa244fe_1-index.json");
18+
let tar_bz2_file_path = Path::new("conda-22.9.0-py38haa244fe_2.tar.bz2");
19+
1820
fs::create_dir(temp_dir.path().join(subdir_path)).unwrap();
1921
fs::copy(
20-
test_data_dir().join(file_path),
21-
temp_dir.path().join(subdir_path).join(file_path),
22+
test_data_dir().join(conda_file_path),
23+
temp_dir.path().join(subdir_path).join(conda_file_path),
24+
)
25+
.unwrap();
26+
fs::copy(
27+
test_data_dir().join(tar_bz2_file_path),
28+
temp_dir.path().join(subdir_path).join(tar_bz2_file_path),
2229
)
2330
.unwrap();
2431

@@ -41,7 +48,11 @@ fn test_index() {
4148
.as_str(),
4249
Some("win-64")
4350
);
44-
assert!(repodata_json.get("packages").is_some());
51+
assert!(repodata_json
52+
.get("packages")
53+
.unwrap()
54+
.get("conda-22.9.0-py38haa244fe_2.tar.bz2")
55+
.is_some());
4556
assert_eq!(
4657
repodata_json
4758
.get("packages.conda")

0 commit comments

Comments
 (0)