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

refactor: Create reader from opendal buffer #1123

Merged
merged 1 commit into from
Feb 28, 2025
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/rattler_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
bytes = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] }
clap-verbosity-flag = { workspace = true, features = ["tracing"] }
console = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions crates/rattler_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![deny(missing_docs)]

use anyhow::Result;
use bytes::buf::Buf;
use fs_err::{self as fs};
use futures::future::try_join_all;
use fxhash::FxHashMap;
Expand Down Expand Up @@ -249,13 +250,12 @@ async fn index_subdir(
));
let file_path = format!("{subdir}/{filename}");
let buffer = op.read(&file_path).await?;
let bytes = buffer.to_vec();
let cursor = Cursor::new(bytes);
let reader = buffer.reader();
// We already know it's not None
let archive_type = ArchiveType::try_from(&filename).unwrap();
let record = match archive_type {
ArchiveType::TarBz2 => package_record_from_tar_bz2_reader(cursor),
ArchiveType::Conda => package_record_from_conda_reader(cursor),
ArchiveType::TarBz2 => package_record_from_tar_bz2_reader(reader),
ArchiveType::Conda => package_record_from_conda_reader(reader),
}?;
pb.inc(1);
Ok::<(String, PackageRecord), std::io::Error>((filename.clone(), record))
Expand Down
Loading