Fix XDG_RUNTIME_DIR dependency by adding fallback to temp directory
parent
e3fce1c0c7
commit
03eccc999f
|
|
@ -6,9 +6,17 @@ use xdg::BaseDirectories;
|
|||
|
||||
/// Get the path to the Cypraea socket.
|
||||
pub fn socket_path() -> Result<PathBuf> {
|
||||
// Use XDG_RUNTIME_DIR if available, or fall back to a temporary directory
|
||||
let xdg = BaseDirectories::new().context("Failed to initialize XDG base directories")?;
|
||||
Ok(xdg.place_runtime_file("cypraea.sock")?)
|
||||
// Try to use XDG_RUNTIME_DIR if available
|
||||
if let Ok(xdg) = BaseDirectories::new() {
|
||||
if let Ok(path) = xdg.place_runtime_file("cypraea.sock") {
|
||||
return Ok(path);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to a temporary directory if XDG_RUNTIME_DIR is not set
|
||||
let tmp_dir = std::env::temp_dir();
|
||||
let socket_path = tmp_dir.join("cypraea.sock");
|
||||
Ok(socket_path)
|
||||
}
|
||||
|
||||
/// Get the path to the Cypraea database directory.
|
||||
|
|
|
|||
Loading…
Reference in New Issue