From fc3ae1e71a540073e6815bb22caee4660fa75028 Mon Sep 17 00:00:00 2001 From: Raine Date: Sat, 14 Oct 2023 22:39:48 +0200 Subject: [PATCH] feat: better time display and tmpdir expands homedir --- pkgr/Cargo.toml | 2 ++ pkgr/src/commands.rs | 2 +- pkgr/src/tmpfs.rs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgr/Cargo.toml b/pkgr/Cargo.toml index cc6e55b..d6b098f 100644 --- a/pkgr/Cargo.toml +++ b/pkgr/Cargo.toml @@ -23,3 +23,5 @@ serde = { version = "1.0.171", features = ["derive"] } libc = "0.2.80" reqwest = { version = "0.11.18", features = ["blocking"] } tar = "0.4.39" +humantime = "2.1.0" +expanduser = "1.2.2" diff --git a/pkgr/src/commands.rs b/pkgr/src/commands.rs index 1df594b..87da700 100644 --- a/pkgr/src/commands.rs +++ b/pkgr/src/commands.rs @@ -94,7 +94,7 @@ impl Command { let duration = end.duration_since(start); info!("Install complete."); - info!("Install took {}ms.", duration.as_nanos() as f64 / 1000000.0); + info!("Install took {}.", humantime::format_duration(duration)); } Command::Remove { package_identifier, diff --git a/pkgr/src/tmpfs.rs b/pkgr/src/tmpfs.rs index 74c21b8..a9b756d 100644 --- a/pkgr/src/tmpfs.rs +++ b/pkgr/src/tmpfs.rs @@ -8,6 +8,8 @@ pub struct TempDir { impl TempDir { pub fn new(path: PathBuf) -> TempDir { + let pbs: String = path.to_str().unwrap().into(); + let path = expanduser::expanduser(&pbs).unwrap(); if !path.exists() { std::fs::create_dir_all(&path).unwrap(); }