diff options
| author | salmon <salmonik@tuta.io> | 2026-08-09 23:53:47 +0200 |
|---|---|---|
| committer | salmon <salmonik@tuta.io> | 2026-08-09 23:53:47 +0200 |
| commit | ce1b4011d409997b10ca205f459cedcb6b292bd7 (patch) | |
| tree | bbfd1572f0d6d3a30478bbfb613a09df0022940b /src/daemon.rs | |
| parent | Make install.sh POSIX sh so it runs without bash (diff) | |
| download | rsplayer-ce1b4011d409997b10ca205f459cedcb6b292bd7.tar.gz rsplayer-ce1b4011d409997b10ca205f459cedcb6b292bd7.zip | |
Make daemon socket/PID paths environment-independent; fix rc service HOME
Diffstat (limited to '')
| -rw-r--r-- | src/daemon.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/daemon.rs b/src/daemon.rs index 279620d..21f1a3b 100644 --- a/src/daemon.rs +++ b/src/daemon.rs | |||
| @@ -203,13 +203,8 @@ pub fn start_daemon() -> Result<(), Box<dyn std::error::Error>> { | |||
| 203 | std::fs::remove_file(&socket_path).ok(); | 203 | std::fs::remove_file(&socket_path).ok(); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | // Create runtime directory | 206 | // Create runtime directory (private, 0700) |
| 207 | if let Some(parent) = socket_path.parent() { | 207 | crate::config::ensure_runtime_dir()?; |
| 208 | std::fs::create_dir_all(parent)?; | ||
| 209 | } | ||
| 210 | if let Some(parent) = pid_path.parent() { | ||
| 211 | std::fs::create_dir_all(parent)?; | ||
| 212 | } | ||
| 213 | 208 | ||
| 214 | // Write PID file | 209 | // Write PID file |
| 215 | let pid = std::process::id(); | 210 | let pid = std::process::id(); |
| @@ -1609,10 +1604,7 @@ fn find_audio_in_dir(dir: &Path) -> Option<Vec<std::path::PathBuf>> { | |||
| 1609 | 1604 | ||
| 1610 | /// Get the PID file path for the daemon | 1605 | /// Get the PID file path for the daemon |
| 1611 | fn get_pid_path(_config: &Config) -> std::path::PathBuf { | 1606 | fn get_pid_path(_config: &Config) -> std::path::PathBuf { |
| 1612 | let runtime_dir = std::env::var("XDG_RUNTIME_DIR") | 1607 | crate::config::runtime_dir().join("rsplayer.pid") |
| 1613 | .map(std::path::PathBuf::from) | ||
| 1614 | .unwrap_or_else(|_| std::path::PathBuf::from("/tmp")); | ||
| 1615 | runtime_dir.join("rsplayer").join("rsplayer.pid") | ||
| 1616 | } | 1608 | } |
| 1617 | 1609 | ||
| 1618 | /// Check if a process with the given PID is running | 1610 | /// Check if a process with the given PID is running |
