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

EXP: try getting standalone manifests working in Rust core #3303

Closed
wants to merge 7 commits into from
Closed
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
28 changes: 28 additions & 0 deletions src/core/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,40 @@
}

pub fn sig_from_record(&self, record: &Record) -> Result<SigStore> {
eprintln!("fetching: {:?}", record);
let match_path = record.internal_location().as_str();
let selection = Selection::from_record(record)?;
let sig = self.storage.load_sig(match_path)?.select(&selection)?;
assert_eq!(sig.signatures.len(), 1);
Ok(sig)
}

pub fn sig_from_record2(&self, record: &Record) -> Result<SigStore> {
eprintln!("fetching: {:?}", record);
let match_path = record.internal_location().as_str();
Ok(match match_path {
x if x.ends_with(".sig") || x.ends_with(".sig.gz") => {
let selection = Selection::from_record(record)?;
let sig = self.storage.load_sig(x)?.select(&selection)?;
assert_eq!(sig.signatures.len(), 1);
sig

Check warning on line 228 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L220-L228

Added lines #L220 - L228 were not covered by tests
}
x if x.ends_with(".zip") => {
let zipcoll = Collection::from_zipfile(x)?;

Check warning on line 231 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L230-L231

Added lines #L230 - L231 were not covered by tests

let ziprec = zipcoll.manifest().iter().find(|r| {
r.md5() == record.md5() && r.name() == record.name()
}).unwrap();
eprintln!("ziprec: {}", ziprec.md5());

Check warning on line 236 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L233-L236

Added lines #L233 - L236 were not covered by tests

let sig = zipcoll.sig_from_record(ziprec)?;

Check warning on line 238 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L238

Added line #L238 was not covered by tests
sig

// todo!("more zip better")
}
_ => todo!("unknown, dying now")

Check warning on line 243 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L243

Added line #L243 was not covered by tests
})
}
}

impl Select for Collection {
Expand All @@ -236,7 +264,7 @@
use crate::prelude::Select;
use crate::selection::Selection;
use crate::signature::Signature;
use crate::Result;

Check warning on line 267 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `crate::Result`

Check warning on line 267 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `crate::Result`

Check warning on line 267 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (windows)

unused import: `crate::Result`

Check warning on line 267 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (macos)

unused import: `crate::Result`

#[test]
fn sigstore_selection_with_downsample() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/index/revindex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl RevIndex {

pub fn open<P: AsRef<Path>>(index: P, read_only: bool, spec: Option<&str>) -> Result<Self> {
let opts = db_options();
let cfs = DB::list_cf(&opts, index.as_ref()).unwrap();
let cfs = DB::list_cf(&opts, index.as_ref())?;

if cfs.into_iter().any(|c| c == COLORS) {
// TODO: ColorRevIndex can't be read-only for now,
Expand Down
Loading