mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-04-21 16:01:56 +00:00
Fix autoupdater
This commit is contained in:
parent
a4bf9e4a55
commit
e88653974b
4 changed files with 38 additions and 49 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
|
@ -1381,7 +1381,6 @@ dependencies = [
|
||||||
"webview2",
|
"webview2",
|
||||||
"webview2-sys",
|
"webview2-sys",
|
||||||
"whoami",
|
"whoami",
|
||||||
"win32job",
|
|
||||||
"winapi",
|
"winapi",
|
||||||
"winres",
|
"winres",
|
||||||
]
|
]
|
||||||
|
|
@ -1486,26 +1485,6 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror"
|
|
||||||
version = "1.0.57"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror-impl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror-impl"
|
|
||||||
version = "1.0.57"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.52",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
|
|
@ -1858,16 +1837,6 @@ version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983"
|
checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "win32job"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5b2b1bf557d947847a30eb73f79aa6cdb3eaf3ce02f5e9599438f77896a62b3c"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror",
|
|
||||||
"windows",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
@ -1896,16 +1865,6 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows"
|
|
||||||
version = "0.52.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
|
||||||
dependencies = [
|
|
||||||
"windows-core",
|
|
||||||
"windows-targets 0.52.4",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ native-windows-derive = "1"
|
||||||
winapi = { version = "0.3.9", features = [
|
winapi = { version = "0.3.9", features = [
|
||||||
"libloaderapi",
|
"libloaderapi",
|
||||||
"handleapi",
|
"handleapi",
|
||||||
|
"jobapi2",
|
||||||
"wincon",
|
"wincon",
|
||||||
"winuser",
|
"winuser",
|
||||||
"namedpipeapi"
|
"namedpipeapi"
|
||||||
|
|
@ -29,7 +30,6 @@ clap = { version = "4", features = ["derive", "unicode"] }
|
||||||
open = "5"
|
open = "5"
|
||||||
urlencoding = "2"
|
urlencoding = "2"
|
||||||
bitflags = "2"
|
bitflags = "2"
|
||||||
win32job = "2"
|
|
||||||
parse-display = "0.9"
|
parse-display = "0.9"
|
||||||
flume = "0.11"
|
flume = "0.11"
|
||||||
whoami = "1.5"
|
whoami = "1.5"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use serde_json;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
io::Read,
|
io::Read,
|
||||||
|
os::windows::process::CommandExt,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::{self, Command},
|
process::{self, Command},
|
||||||
str,
|
str,
|
||||||
|
|
@ -12,7 +13,7 @@ use std::{
|
||||||
thread, time,
|
thread, time,
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use winapi::um::winuser::WS_EX_TOPMOST;
|
use winapi::um::{winbase::CREATE_BREAKAWAY_FROM_JOB, winuser::WS_EX_TOPMOST};
|
||||||
|
|
||||||
use crate::stremio_app::{
|
use crate::stremio_app::{
|
||||||
constants::{APP_NAME, UPDATE_ENDPOINT, UPDATE_INTERVAL, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH},
|
constants::{APP_NAME, UPDATE_ENDPOINT, UPDATE_INTERVAL, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH},
|
||||||
|
|
@ -273,6 +274,8 @@ impl MainWindow {
|
||||||
"/FORCECLOSEAPPLICATIONS",
|
"/FORCECLOSEAPPLICATIONS",
|
||||||
"/TASKS=runapp",
|
"/TASKS=runapp",
|
||||||
])
|
])
|
||||||
|
.creation_flags(CREATE_BREAKAWAY_FROM_JOB)
|
||||||
|
.stdin(process::Stdio::null())
|
||||||
.stdout(process::Stdio::null())
|
.stdout(process::Stdio::null())
|
||||||
.stderr(process::Stdio::null())
|
.stderr(process::Stdio::null())
|
||||||
.spawn();
|
.spawn();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,15 @@ use std::os::windows::process::CommandExt;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use win32job::Job;
|
use winapi::um::{
|
||||||
|
processthreadsapi::GetCurrentProcess,
|
||||||
|
winbase::CreateJobObjectA,
|
||||||
|
winnt::{
|
||||||
|
JobObjectExtendedLimitInformation, JOBOBJECT_BASIC_LIMIT_INFORMATION,
|
||||||
|
JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOB_OBJECT_LIMIT_BREAKAWAY_OK,
|
||||||
|
JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||||
|
|
||||||
|
|
@ -12,11 +20,30 @@ pub struct StremioServer {}
|
||||||
impl StremioServer {
|
impl StremioServer {
|
||||||
pub fn new() -> StremioServer {
|
pub fn new() -> StremioServer {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let job = Job::create().expect("Cannont create job");
|
// Use Win32JobObject to kill the child process when the parent process is killed
|
||||||
let mut info = job.query_extended_limit_info().expect("Cannont get info");
|
// With the JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK and JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flags
|
||||||
info.limit_kill_on_job_close();
|
unsafe {
|
||||||
job.set_extended_limit_info(&info).ok();
|
let job_main_process = CreateJobObjectA(std::ptr::null_mut(), std::ptr::null_mut());
|
||||||
job.assign_current_process().ok();
|
let jeli = JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
|
||||||
|
BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION {
|
||||||
|
LimitFlags: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
|
||||||
|
| JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION
|
||||||
|
| JOB_OBJECT_LIMIT_BREAKAWAY_OK,
|
||||||
|
..std::mem::zeroed()
|
||||||
|
},
|
||||||
|
..std::mem::zeroed()
|
||||||
|
};
|
||||||
|
winapi::um::jobapi2::SetInformationJobObject(
|
||||||
|
job_main_process,
|
||||||
|
JobObjectExtendedLimitInformation,
|
||||||
|
&jeli as *const _ as *mut _,
|
||||||
|
std::mem::size_of::<JOBOBJECT_EXTENDED_LIMIT_INFORMATION>() as u32,
|
||||||
|
);
|
||||||
|
winapi::um::jobapi2::AssignProcessToJobObject(
|
||||||
|
job_main_process,
|
||||||
|
GetCurrentProcess(),
|
||||||
|
);
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
let child = Command::new("./stremio-runtime")
|
let child = Command::new("./stremio-runtime")
|
||||||
.arg("server.js")
|
.arg("server.js")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue