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

fix: small issues I encountered #184

Merged
merged 1 commit into from
May 1, 2023
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
7 changes: 7 additions & 0 deletions crates/rattler_conda_types/src/conda_lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ impl CondaLock {
pub fn from_path(path: &Path) -> Result<Self, ParseCondaLockError> {
Self::from_reader(File::open(path)?)
}

/// Writes the conda lock to a file
pub fn to_path(&self, path: &Path) -> Result<(), std::io::Error> {
let file = std::fs::File::create(path)?;
serde_yaml::to_writer(file, self)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))
}
}

#[derive(Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/repo_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct ChannelInfo {
#[serde_as]
#[skip_serializing_none]
#[sorted]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone)]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone, Hash)]
pub struct PackageRecord {
/// Optionally the architecture the package supports
pub arch: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/repo_data_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use url::Url;

/// Information about a package from repodata. It includes a [`crate::PackageRecord`] but it also stores
/// the source of the data (like the url and the channel).
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone)]
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone, Hash)]
pub struct RepoDataRecord {
/// The data stored in the repodata.json.
#[serde(flatten)]
Expand Down
11 changes: 9 additions & 2 deletions crates/rattler_repodata_gateway/src/sparse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ impl SparseRepoData {
///
/// This will parse the records for the specified packages as well as all the packages these records
/// depend on.
pub fn load_records_recursive(
repo_data: &[SparseRepoData],
pub fn load_records_recursive<'a>(
repo_data: impl IntoIterator<Item = &'a SparseRepoData>,
package_names: impl IntoIterator<Item = impl Into<String>>,
) -> io::Result<Vec<Vec<RepoDataRecord>>> {
let repo_data: Vec<_> = repo_data.into_iter().collect();

// Construct the result map
let mut result = Vec::from_iter((0..repo_data.len()).map(|_| Vec::new()));

Expand Down Expand Up @@ -155,6 +157,11 @@ impl SparseRepoData {

Ok(result)
}

/// Returns the subdirectory from which this repodata was loaded
pub fn subdir(&self) -> &str {
&self.subdir
}
}

/// A serde compatible struct that only sparsely parses a repodata.json file.
Expand Down