From 5b6083d1b07e0771fe39a905c634421a16424a05 Mon Sep 17 00:00:00 2001 From: d10sfan Date: Mon, 11 Sep 2023 21:18:07 -0500 Subject: [PATCH] Remove unnecessary code and dependency around xdg_runtime_dir --- Cargo.lock | 11 ----------- Cargo.toml | 1 - src/command.rs | 1 - src/user_env.rs | 21 --------------------- 4 files changed, 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a142590b..11b4e478 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,7 +1070,6 @@ dependencies = [ "steamlocate", "tar", "tokio", - "users", "walkdir", "which", "xdg", @@ -2156,16 +2155,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "users" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" -dependencies = [ - "libc", - "log", -] - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index c3f6571b..e1cdaef9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ serde_regex = "1.1" json = "0.12.4" regex = "1.9.3" reqwest = { version = "0.11.19", features = ["rustls-tls", "blocking", "gzip", "stream"], default-features = false } -users = "0.11" xdg = "2.5.2" tar = "0.4.40" xz2 = "0.1.7" diff --git a/src/command.rs b/src/command.rs index d9b6d688..28739df2 100644 --- a/src/command.rs +++ b/src/command.rs @@ -564,7 +564,6 @@ pub fn main() -> io::Result<()> { std::process::exit(0) } - user_env::assure_xdg_runtime_dir()?; user_env::assure_tool_dir(args[0])?; match env::var(LUX_WRITE_LOGGING) { diff --git a/src/user_env.rs b/src/user_env.rs index e55968d5..d3d35b8d 100644 --- a/src/user_env.rs +++ b/src/user_env.rs @@ -1,38 +1,17 @@ -extern crate users; extern crate xdg; use log::warn; use std::env; -use std::fs; -use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::path::PathBuf; use crate::command; -use users::get_current_uid; -static XDG_RUNTIME_DIR: &str = "XDG_RUNTIME_DIR"; static LUX_TOOL_DIR: &str = "LUX_TOOL_DIR"; static STEAM_APPID: &str = "SteamAppId"; static LUX_CONTROLLER: &str = "LUX_CONTROLLER"; static STEAM_COMPAT_CLIENT_INSTALL_PATH: &str = "STEAM_COMPAT_CLIENT_INSTALL_PATH"; -/// Assure, that XDG_RUNTIME_DIR is set with correct access mode. -/// -pub fn assure_xdg_runtime_dir() -> Result<(), std::io::Error> { - let xdg_dirs = xdg::BaseDirectories::new()?; - if xdg_dirs.has_runtime_directory() { - return Ok(()); - } - let runtime_dir = format!("/tmp/luxtorpeda_{}", get_current_uid()); - if !Path::new(&runtime_dir).is_dir() { - fs::create_dir(&runtime_dir)?; - } - fs::set_permissions(&runtime_dir, fs::Permissions::from_mode(0o700))?; - env::set_var(XDG_RUNTIME_DIR, &runtime_dir); - Ok(()) -} - pub fn assure_tool_dir(arg0: &str) -> Result<(), std::io::Error> { let tool_path = Path::new(arg0); env::set_var(LUX_TOOL_DIR, tool_path.parent().unwrap());