Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 4, 2024
1 parent c828926 commit 9f30650
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions rust/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 rust/agama-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async-trait = "0.1.83"
reqwest = { version = "0.11", features = ["json"] }
url = "2.5.2"
inquire = { version = "0.7.5", default-features = false, features = ["crossterm", "one-liners"] }
chrono = "0.4.38"

[[bin]]
name = "agama"
Expand Down
17 changes: 10 additions & 7 deletions rust/agama-cli/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ pub async fn run(client: BaseHTTPClient, subcommand: LogsCommands) -> anyhow::Re
} => {
// feed internal options structure by what was received from user
// for now we always use / add defaults if any
let destination = parse_destination(destination)?;

let destination = client
.store(destination.as_path())
let dst_file = parse_destination(destination)?;
let result = client
.store(dst_file.as_path())
.await
.map_err(|_| anyhow::Error::msg("Downloading of logs failed"))?;

set_archive_permissions(destination.clone())
set_archive_permissions(result.clone())
.map_err(|_| anyhow::Error::msg("Cannot store the logs"))?;

showln(verbose, format!("{:?}", destination.clone()).as_str());
showln(verbose, format!("{:?}", result.clone()).as_str());

Ok(())
}
Expand Down Expand Up @@ -108,7 +107,11 @@ pub async fn run(client: BaseHTTPClient, subcommand: LogsCommands) -> anyhow::Re
/// be appended later on (depends on used compression)
fn parse_destination(destination: Option<PathBuf>) -> Result<PathBuf, io::Error> {
let err = io::Error::new(io::ErrorKind::InvalidInput, "Invalid destination path");
let mut buffer = destination.unwrap_or(PathBuf::from(DEFAULT_RESULT));
let mut buffer = destination.unwrap_or(PathBuf::from(format!(
"{}-{}",
DEFAULT_RESULT,
chrono::prelude::Utc::now().timestamp()
)));
let path = buffer.as_path();

// existing directory -> append an archive name
Expand Down

0 comments on commit 9f30650

Please sign in to comment.