Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Apr 5, 2024
1 parent ef70a37 commit 6174768
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bws/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ async fn process_commands() -> Result<()> {
let state_file_path = state::get_state_file_path(
profile.and_then(|p| p.state_file_dir).map(Into::into),
access_token_obj.access_token_id.to_string(),
);
)?;

Check warning on line 331 in crates/bws/src/main.rs

View check run for this annotation

Codecov / codecov/patch

crates/bws/src/main.rs#L331

Added line #L331 was not covered by tests

let mut client = bitwarden::Client::new(settings);

Expand Down
10 changes: 6 additions & 4 deletions crates/bws/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use std::path::PathBuf;

use color_eyre::eyre::Result;

pub(crate) fn get_state_file_path(
state_file_dir: Option<PathBuf>,
access_token_id: String,
) -> Option<PathBuf> {
) -> Result<Option<PathBuf>> {

Check warning on line 8 in crates/bws/src/state.rs

View check run for this annotation

Codecov / codecov/patch

crates/bws/src/state.rs#L8

Added line #L8 was not covered by tests
if let Some(mut state_file_path) = state_file_dir {
state_file_path.push(access_token_id);

if let Some(parent_folder) = state_file_path.parent() {
std::fs::create_dir_all(parent_folder).expect("Parent directory should be writable");
std::fs::create_dir_all(parent_folder)?;

Check warning on line 13 in crates/bws/src/state.rs

View check run for this annotation

Codecov / codecov/patch

crates/bws/src/state.rs#L13

Added line #L13 was not covered by tests
}

return Some(state_file_path);
return Ok(Some(state_file_path));

Check warning on line 16 in crates/bws/src/state.rs

View check run for this annotation

Codecov / codecov/patch

crates/bws/src/state.rs#L16

Added line #L16 was not covered by tests
}

None
Ok(None)

Check warning on line 19 in crates/bws/src/state.rs

View check run for this annotation

Codecov / codecov/patch

crates/bws/src/state.rs#L19

Added line #L19 was not covered by tests
}

0 comments on commit 6174768

Please sign in to comment.