Skip to content

Commit

Permalink
Remove unnecessary code and dependency around xdg_runtime_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
d10sfan committed Sep 12, 2023
1 parent e80b6d0 commit 5b6083d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 34 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 0 additions & 21 deletions src/user_env.rs
Original file line number Diff line number Diff line change
@@ -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());
Expand Down

0 comments on commit 5b6083d

Please sign in to comment.