Skip to content

Commit

Permalink
Updates error handling when finding path providers
Browse files Browse the repository at this point in the history
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
  • Loading branch information
dcookspi committed Aug 1, 2023
1 parent 24dd4da commit 066a35c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 10 additions & 2 deletions crates/spk-cli/group4/src/cmd_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@ impl View {
// contain this file. Each of them should contain at least a
// layer and the filepath entry, but might contain other spfs
// objects.
let (in_a_runtime, found) = spk_storage::find_path_providers(filepath).await?;
let mut in_a_runtime = true;
let found = match spk_storage::find_path_providers(filepath).await {
Ok(f) => f,

Check warning on line 202 in crates/spk-cli/group4/src/cmd_view.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-cli/group4/src/cmd_view.rs#L200-L202

Added lines #L200 - L202 were not covered by tests
Err(spk_storage::Error::SPFS(spfs::Error::NoActiveRuntime)) => {
in_a_runtime = false;
Vec::new()

Check warning on line 205 in crates/spk-cli/group4/src/cmd_view.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-cli/group4/src/cmd_view.rs#L204-L205

Added lines #L204 - L205 were not covered by tests
}
Err(err) => return Err(err.into()),

Check warning on line 207 in crates/spk-cli/group4/src/cmd_view.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-cli/group4/src/cmd_view.rs#L207

Added line #L207 was not covered by tests
};

if found.is_empty() {
println!("{filepath}: {}", "not found".yellow());
Expand Down Expand Up @@ -279,7 +287,7 @@ impl View {
println!(

Check warning on line 287 in crates/spk-cli/group4/src/cmd_view.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-cli/group4/src/cmd_view.rs#L285-L287

Added lines #L285 - L287 were not covered by tests
" {}",
solved_request.request.format_request(
&solved_request.repo_name(),
solved_request.repo_name().as_ref(),
&solved_request.request.pkg.name,

Check warning on line 291 in crates/spk-cli/group4/src/cmd_view.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-cli/group4/src/cmd_view.rs#L289-L291

Added lines #L289 - L291 were not covered by tests
&FormatChangeOptions {
verbosity: DONT_SHOW_DETAILED_SETTINGS,
Expand Down
9 changes: 3 additions & 6 deletions crates/spk-storage/src/storage/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;

use itertools::Itertools;
use relative_path::RelativePathBuf;
use spfs::find_path::ObjectPathEntry;
use spfs::find_path::ObjectPath;
use spfs::io::DigestFormat;
use spfs::prelude::*;
use spk_schema::foundation::ident_build::parse_build;
Expand Down Expand Up @@ -579,7 +579,7 @@ async fn find_layers_by_filenames<S: AsRef<str>>(

/// Return a list of spfs object lists that lead to the given
/// filepath in the runtime repo.
pub async fn find_path_providers(filepath: &str) -> Result<(bool, Vec<Vec<ObjectPathEntry>>)> {
pub async fn find_path_providers(filepath: &str) -> Result<Vec<ObjectPath>> {
let config = spfs::get_config()?;
let repo = config.get_local_repository_handle().await?;

Check warning on line 584 in crates/spk-storage/src/storage/runtime.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-storage/src/storage/runtime.rs#L582-L584

Added lines #L582 - L584 were not covered by tests

Expand All @@ -589,10 +589,7 @@ pub async fn find_path_providers(filepath: &str) -> Result<(bool, Vec<Vec<Object
}

/// Print out a spfs object list down to the given filepath
pub async fn pretty_print_filepath(
filepath: &str,
objectpath: &Vec<ObjectPathEntry>,
) -> Result<()> {
pub async fn pretty_print_filepath(filepath: &str, objectpath: &ObjectPath) -> Result<()> {
let config = spfs::get_config()?;
let repo = config.get_local_repository_handle().await?;

Check warning on line 594 in crates/spk-storage/src/storage/runtime.rs

View check run for this annotation

Codecov / codecov/patch

crates/spk-storage/src/storage/runtime.rs#L592-L594

Added lines #L592 - L594 were not covered by tests

Expand Down

0 comments on commit 066a35c

Please sign in to comment.