Skip to content

Commit

Permalink
refactor: create reader from opendal buffer (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Feb 28, 2025
1 parent 9466e38 commit 6e13ecb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit 6e13ecb

Please sign in to comment.