mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 11:25:56 +00:00
Merge branch 'review/pr5' into release/0.6.0
# Conflicts: # src-tauri/src/lib.rs
This commit is contained in:
commit
79d293e120
3 files changed
+52
No files matched your search
@@ -70,11 +70,24 @@ struct StatusView {
|
||||
path_exists: bool,
|
||||
}
|
||||
|
||||
/// Where the Manager keeps its own state (server list, logs). `%LOCALAPPDATA%` on Windows, the XDG data folder elsewhere.
|
||||
fn data_dir() -> PathBuf {
|
||||
#[cfg(windows)]
|
||||
let base = std::env::var_os("LOCALAPPDATA").map(PathBuf::from).unwrap_or_else(std::env::temp_dir);
|
||||
#[cfg(not(windows))]
|
||||
let base = unix_data_home(std::env::var_os("XDG_DATA_HOME"), std::env::var_os("HOME"));
|
||||
base.join("CoAServerManager")
|
||||
}
|
||||
|
||||
/// `$XDG_DATA_HOME` when it is an absolute path (the spec says to ignore relative ones), else `~/.local/share`.
|
||||
#[cfg(not(windows))]
|
||||
fn unix_data_home(xdg: Option<std::ffi::OsString>, home: Option<std::ffi::OsString>) -> PathBuf {
|
||||
xdg.map(PathBuf::from)
|
||||
.filter(|p| p.is_absolute())
|
||||
.or_else(|| home.map(|h| PathBuf::from(h).join(".local/share")))
|
||||
.unwrap_or_else(std::env::temp_dir)
|
||||
}
|
||||
|
||||
fn path_of(state: &AppState, id: &str) -> Result<PathBuf> {
|
||||
state
|
||||
.registry
|
||||
@@ -1478,3 +1491,30 @@ pub fn run() {
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running CoA Server Manager");
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(windows)))]
|
||||
mod tests {
|
||||
use super::unix_data_home;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn os(s: &str) -> Option<OsString> {
|
||||
Some(s.into())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_home_prefers_an_absolute_xdg_folder() {
|
||||
assert_eq!(unix_data_home(os("/data/xdg"), os("/home/u")), PathBuf::from("/data/xdg"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_home_ignores_a_relative_xdg_folder_and_falls_back_to_home() {
|
||||
assert_eq!(unix_data_home(os("relative/dir"), os("/home/u")), PathBuf::from("/home/u/.local/share"));
|
||||
assert_eq!(unix_data_home(None, os("/home/u")), PathBuf::from("/home/u/.local/share"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_home_without_any_variable_uses_the_temp_folder() {
|
||||
assert_eq!(unix_data_home(None, None), std::env::temp_dir());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
// WebKitGTK's DMA-BUF renderer ends the process with a Wayland "Protocol error" on some graphics stacks (seen with
|
||||
// an NVIDIA card on Wayland). The path without it works everywhere; a value set by the user is left alone.
|
||||
#[cfg(target_os = "linux")]
|
||||
if std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_none() {
|
||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
}
|
||||
coa_server_manager_lib::run()
|
||||
}
|
||||
Reference in new issue
Block a user