mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 01:09:56 -05:00
Fix: Added ServerBinary Off & Flatpak Patches
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::ServerState;
|
||||
use tauri::Manager;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn spawn_server(binary: String, app: tauri::AppHandle) -> Result<(), SpawnError> {
|
||||
pub fn spawn_server(binary: String, web_ui_enabled: bool, app: tauri::AppHandle) -> Result<(), SpawnError> {
|
||||
{
|
||||
let state = app.state::<ServerState>();
|
||||
if state.0.lock().unwrap().is_some() {
|
||||
@@ -22,10 +22,10 @@ pub fn spawn_server(binary: String, app: tauri::AppHandle) -> Result<(), SpawnEr
|
||||
|
||||
server::do_log(
|
||||
&mut log,
|
||||
&format!("[spawn_server] binary={:?} data_dir={:?}", binary, data_dir),
|
||||
&format!("[spawn_server] binary={:?} web_ui_enabled={} data_dir={:?}", binary, web_ui_enabled, data_dir),
|
||||
);
|
||||
|
||||
server::conf::seed_server_conf(&data_dir);
|
||||
server::conf::seed_server_conf(&data_dir, web_ui_enabled);
|
||||
|
||||
let mut invocation =
|
||||
server::resolve::resolve_server_binary(&binary, &app, &mut log).map_err(|e| {
|
||||
@@ -77,4 +77,4 @@ pub fn spawn_server(binary: String, app: tauri::AppHandle) -> Result<(), SpawnEr
|
||||
pub fn kill_server(app: tauri::AppHandle) -> Result<(), String> {
|
||||
server::kill_tachidesk(&app);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ use std::path::PathBuf;
|
||||
|
||||
const DEFAULT_SERVER_CONF: &str = r#"server.ip = "127.0.0.1"
|
||||
server.port = 4567
|
||||
server.webUIEnabled = true
|
||||
server.webUIEnabled = false
|
||||
server.initialOpenInBrowserEnabled = false
|
||||
server.systemTrayEnabled = false
|
||||
server.webUIInterface = "browser"
|
||||
@@ -17,7 +17,7 @@ server.maxSourcesInParallel = 6
|
||||
server.extensionRepos = []
|
||||
"#;
|
||||
|
||||
pub fn seed_server_conf(data_dir: &PathBuf) {
|
||||
pub fn seed_server_conf(data_dir: &PathBuf, web_ui_enabled: bool) {
|
||||
let conf_path = data_dir.join("server.conf");
|
||||
|
||||
if !conf_path.exists() {
|
||||
@@ -25,7 +25,12 @@ pub fn seed_server_conf(data_dir: &PathBuf) {
|
||||
eprintln!("Could not create Suwayomi data dir: {e}");
|
||||
return;
|
||||
}
|
||||
if let Err(e) = std::fs::write(&conf_path, DEFAULT_SERVER_CONF) {
|
||||
let initial = patch_conf_key(
|
||||
DEFAULT_SERVER_CONF.to_string(),
|
||||
"server.webUIEnabled",
|
||||
if web_ui_enabled { "true" } else { "false" },
|
||||
);
|
||||
if let Err(e) = std::fs::write(&conf_path, initial) {
|
||||
eprintln!("Could not write server.conf: {e}");
|
||||
}
|
||||
return;
|
||||
@@ -37,7 +42,11 @@ pub fn seed_server_conf(data_dir: &PathBuf) {
|
||||
|
||||
let patched = patch_conf_key(
|
||||
patch_conf_key(
|
||||
patch_conf_key(contents, "server.webUIEnabled", "true"),
|
||||
patch_conf_key(
|
||||
contents,
|
||||
"server.webUIEnabled",
|
||||
if web_ui_enabled { "true" } else { "false" },
|
||||
),
|
||||
"server.initialOpenInBrowserEnabled",
|
||||
"false",
|
||||
),
|
||||
@@ -70,4 +79,4 @@ fn patch_conf_key(text: String, key: &str, value: &str) -> String {
|
||||
out.push_str(&replacement);
|
||||
out.push('\n');
|
||||
out
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user