mirror of
https://github.com/nukesor/pueue
synced 2024-10-02 22:13:56 +00:00
Switch from users crate to whoami
This commit is contained in:
parent
7a2e7013bd
commit
e04e25d6ff
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -1164,8 +1164,8 @@ dependencies = [
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"snap",
|
"snap",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"users",
|
|
||||||
"version_check",
|
"version_check",
|
||||||
|
"whoami",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1192,7 +1192,7 @@ dependencies = [
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"snap",
|
"snap",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"users",
|
"whoami",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1839,6 +1839,16 @@ dependencies = [
|
||||||
"cc",
|
"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]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
|
@ -17,9 +17,9 @@ maintenance = { status = "actively-developed" }
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
dirs = "3"
|
dirs = "3"
|
||||||
chrono = { version = "^0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
rand = "^0.8"
|
rand = "0.8"
|
||||||
strum_macros = "^0.20"
|
strum_macros = "0.20"
|
||||||
|
|
||||||
async-std = { version = "1", features = ["attributes", "std"] }
|
async-std = { version = "1", features = ["attributes", "std"] }
|
||||||
async-tls = "0.11"
|
async-tls = "0.11"
|
||||||
|
@ -27,16 +27,16 @@ async-trait = "0.1"
|
||||||
rustls = "0.19"
|
rustls = "0.19"
|
||||||
rev_lines = "0.2"
|
rev_lines = "0.2"
|
||||||
rcgen = "0.8"
|
rcgen = "0.8"
|
||||||
byteorder = "^1"
|
byteorder = "1"
|
||||||
snap = "1"
|
snap = "1"
|
||||||
serde = "^1.0"
|
serde = "1"
|
||||||
bincode = "^1.2"
|
bincode = "1"
|
||||||
serde_json = "^1.0"
|
serde_json = "1"
|
||||||
serde_yaml = "^0.8"
|
serde_yaml = "0.8"
|
||||||
serde_derive = "^1.0"
|
serde_derive = "1"
|
||||||
|
|
||||||
config = { version = "^0.10", default-features = false, features = ["yaml"] }
|
config = { version = "^0.10", default-features = false, features = ["yaml"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
users = "^0.11"
|
whoami = "^1"
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use users::{get_current_uid, get_user_by_uid};
|
|
||||||
|
|
||||||
/// Get the default unix socket path for the current user
|
/// Get the default unix socket path for the current user
|
||||||
pub fn get_unix_socket_path() -> Result<String> {
|
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
|
// Create the socket in the default pueue path
|
||||||
let pueue_path = PathBuf::from(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
|
Ok(path
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| anyhow!("Failed to parse log path (Weird characters?)"))?
|
.ok_or_else(|| anyhow!("Failed to parse log path (Weird characters?)"))?
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use users::{get_current_uid, get_user_by_uid};
|
|
||||||
|
|
||||||
/// Get the default unix socket path for the current user
|
/// Get the default unix socket path for the current user
|
||||||
pub fn get_unix_socket_path() -> Result<String> {
|
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
|
// Create the socket in the default pueue path
|
||||||
let pueue_path = PathBuf::from(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
|
Ok(path
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or(anyhow!("Failed to parse log path (Weird characters?)"))?
|
.ok_or(anyhow!("Failed to parse log path (Weird characters?)"))?
|
||||||
|
|
|
@ -14,30 +14,6 @@ edition = "2018"
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "actively-developed" }
|
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]]
|
[[bin]]
|
||||||
name = "pueue"
|
name = "pueue"
|
||||||
path = "client/main.rs"
|
path = "client/main.rs"
|
||||||
|
@ -46,15 +22,39 @@ path = "client/main.rs"
|
||||||
name = "pueued"
|
name = "pueued"
|
||||||
path = "daemon/main.rs"
|
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]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
nix = "^0.19"
|
nix = "0.19"
|
||||||
users = "^0.11"
|
whoami = "1"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
|
||||||
procfs = { version = "0.9", default-features = false }
|
procfs = { version = "0.9", default-features = false }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
psutil = "^3"
|
psutil = "3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
version_check = "^0.9"
|
version_check = "0.9"
|
||||||
|
|
Loading…
Reference in a new issue