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.
|
/// Get the path to the Cypraea socket.
|
||||||
pub fn socket_path() -> Result<PathBuf> {
|
pub fn socket_path() -> Result<PathBuf> {
|
||||||
// Use XDG_RUNTIME_DIR if available, or fall back to a temporary directory
|
// Try to use XDG_RUNTIME_DIR if available
|
||||||
let xdg = BaseDirectories::new().context("Failed to initialize XDG base directories")?;
|
if let Ok(xdg) = BaseDirectories::new() {
|
||||||
Ok(xdg.place_runtime_file("cypraea.sock")?)
|
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.
|
/// Get the path to the Cypraea database directory.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue