1
0
mirror of https://github.com/nukesor/pueue synced 2024-07-03 08:08:36 +00:00

Switch from users crate to whoami

This commit is contained in:
Arne Beer 2021-01-29 16:11:42 +01:00
parent 7a2e7013bd
commit e04e25d6ff
5 changed files with 52 additions and 54 deletions

14
Cargo.lock generated
View File

@ -1164,8 +1164,8 @@ dependencies = [
"simplelog",
"snap",
"tempfile",
"users",
"version_check",
"whoami",
]
[[package]]
@ -1192,7 +1192,7 @@ dependencies = [
"serde_yaml",
"snap",
"strum_macros",
"users",
"whoami",
]
[[package]]
@ -1839,6 +1839,16 @@ dependencies = [
"cc",
]
[[package]]
name = "whoami"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a921c0ad578a51c0b6c0bbb9b95f0ed11e90d61da506139e48a946edd11ee1e"
dependencies = [
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -17,9 +17,9 @@ maintenance = { status = "actively-developed" }
[dependencies]
anyhow = "1"
dirs = "3"
chrono = { version = "^0.4", features = ["serde"] }
rand = "^0.8"
strum_macros = "^0.20"
chrono = { version = "0.4", features = ["serde"] }
rand = "0.8"
strum_macros = "0.20"
async-std = { version = "1", features = ["attributes", "std"] }
async-tls = "0.11"
@ -27,16 +27,16 @@ async-trait = "0.1"
rustls = "0.19"
rev_lines = "0.2"
rcgen = "0.8"
byteorder = "^1"
byteorder = "1"
snap = "1"
serde = "^1.0"
bincode = "^1.2"
serde_json = "^1.0"
serde_yaml = "^0.8"
serde_derive = "^1.0"
serde = "1"
bincode = "1"
serde_json = "1"
serde_yaml = "0.8"
serde_derive = "1"
config = { version = "^0.10", default-features = false, features = ["yaml"] }
log = "0.4"
[target.'cfg(not(windows))'.dependencies]
users = "^0.11"
whoami = "^1"

View File

@ -1,18 +1,12 @@
use std::path::{Path, PathBuf};
use anyhow::{anyhow, Result};
use users::{get_current_uid, get_user_by_uid};
/// Get the default unix socket path for the current user
pub fn get_unix_socket_path() -> Result<String> {
// Get the user and their username
let user = get_user_by_uid(get_current_uid())
.ok_or_else(|| anyhow!("Couldn't find username for current user"))?;
let username = user.name().to_string_lossy();
// Create the socket in the default pueue path
let pueue_path = PathBuf::from(default_pueue_path()?);
let path = pueue_path.join(format!("pueue_{}.socket", username));
let path = pueue_path.join(format!("pueue_{}.socket", whoami::username()));
Ok(path
.to_str()
.ok_or_else(|| anyhow!("Failed to parse log path (Weird characters?)"))?

View File

@ -1,18 +1,12 @@
use std::path::{Path, PathBuf};
use anyhow::{anyhow, Result};
use users::{get_current_uid, get_user_by_uid};
/// Get the default unix socket path for the current user
pub fn get_unix_socket_path() -> Result<String> {
// Get the user and their username
let user = get_user_by_uid(get_current_uid())
.ok_or(anyhow!("Couldn't find username for current user"))?;
let username = user.name().to_string_lossy();
// Create the socket in the default pueue path
let pueue_path = PathBuf::from(default_pueue_path()?);
let path = pueue_path.join(format!("pueue_{}.socket", username));
let path = pueue_path.join(format!("pueue_{}.socket", whoami::username()));
Ok(path
.to_str()
.ok_or(anyhow!("Failed to parse log path (Weird characters?)"))?

View File

@ -14,30 +14,6 @@ edition = "2018"
[badges]
maintenance = { status = "actively-developed" }
[dependencies]
pueue-lib = { version = "0.11.1"}
#pueue-lib = { path = "../pueue-lib" }
anyhow = "1"
chrono = { version = "^0.4", features = ["serde"] }
chrono-english = "^0.1.0"
shell-escape = "^0.1"
tempfile = "^3"
async-std = { version = "1", features = ["attributes", "std"] }
snap = "1"
serde_json = "^1.0"
log = "0.4"
simplelog = { version = "0.9", default-features = false }
clap = "3.0.0-beta.2"
clap_generate = "3.0.0-beta.2"
crossterm = "^0.19"
comfy-table= "^2"
handlebars = "3"
ctrlc = { version = "3", features = ["termination"] }
[[bin]]
name = "pueue"
path = "client/main.rs"
@ -46,15 +22,39 @@ path = "client/main.rs"
name = "pueued"
path = "daemon/main.rs"
[dependencies]
pueue-lib = { version = "0.11"}
#pueue-lib = { path = "../pueue-lib" }
anyhow = "1"
chrono = { version = "0.4", features = ["serde"] }
chrono-english = "0.1"
shell-escape = "0.1"
tempfile = "3"
async-std = { version = "1", features = ["attributes", "std"] }
snap = "1"
serde_json = "1"
log = "0.4"
simplelog = { version = "0.9", default-features = false }
clap = "3.0.0-beta.2"
clap_generate = "3.0.0-beta.2"
crossterm = "0.19"
comfy-table= "2"
handlebars = "3"
ctrlc = { version = "3", features = ["termination"] }
[target.'cfg(not(windows))'.dependencies]
nix = "^0.19"
users = "^0.11"
nix = "0.19"
whoami = "1"
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
procfs = { version = "0.9", default-features = false }
[target.'cfg(target_os = "macos")'.dependencies]
psutil = "^3"
psutil = "3"
[build-dependencies]
version_check = "^0.9"
version_check = "0.9"