mirror of
https://github.com/beerpiss/saekawa.git
synced 2024-11-14 10:37:40 +01:00
fix: actually respect the auto-update configuration
This commit is contained in:
parent
8a0507f03c
commit
2abbd7b79d
15
src/lib.rs
15
src/lib.rs
@ -20,7 +20,6 @@ use crate::{
|
|||||||
helpers::winapi_ext::LibraryHandle,
|
helpers::winapi_ext::LibraryHandle,
|
||||||
logging::init_logger,
|
logging::init_logger,
|
||||||
saekawa::{hook_init, hook_release},
|
saekawa::{hook_init, hook_release},
|
||||||
updater::self_update,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -45,19 +44,7 @@ extern "system" fn DllMain(dll_module: HINSTANCE, call_reason: DWORD, reserved:
|
|||||||
env!("VERGEN_GIT_BRANCH"),
|
env!("VERGEN_GIT_BRANCH"),
|
||||||
);
|
);
|
||||||
|
|
||||||
match self_update(&library_handle) {
|
if let Err(e) = hook_init(library_handle) {
|
||||||
Ok(should_reboot) => {
|
|
||||||
if should_reboot {
|
|
||||||
info!("Self-update successful. Reloading into new hook...");
|
|
||||||
library_handle.free_and_exit_thread(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
error!("Self-update failed: {e:#}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(e) = hook_init() {
|
|
||||||
error!("Failed to initialize hook: {e:#}");
|
error!("Failed to initialize hook: {e:#}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,11 +25,11 @@ use crate::{
|
|||||||
config::{ConfigLoadError, SaekawaConfig},
|
config::{ConfigLoadError, SaekawaConfig},
|
||||||
helpers::{
|
helpers::{
|
||||||
chuni_encoding::{decrypt_aes256_cbc, hash_endpoint, maybe_decompress_buffer},
|
chuni_encoding::{decrypt_aes256_cbc, hash_endpoint, maybe_decompress_buffer},
|
||||||
winapi_ext::{winhttp_query_option, ReadStringFnError},
|
winapi_ext::{winhttp_query_option, LibraryHandle, ReadStringFnError},
|
||||||
},
|
},
|
||||||
score_import::execute_score_import,
|
score_import::execute_score_import,
|
||||||
sigscan::{self, CryptoKeys},
|
sigscan::{self, CryptoKeys},
|
||||||
types::{chuni::UpsertUserAllRequest, ToBatchManual},
|
types::{chuni::UpsertUserAllRequest, ToBatchManual}, updater::self_update,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Snafu)]
|
#[derive(Debug, Snafu)]
|
||||||
@ -96,10 +96,24 @@ static UPSERT_USER_ALL_API: OnceLock<String> = OnceLock::new();
|
|||||||
|
|
||||||
static CONFIG: OnceLock<SaekawaConfig> = OnceLock::new();
|
static CONFIG: OnceLock<SaekawaConfig> = OnceLock::new();
|
||||||
|
|
||||||
pub fn hook_init() -> Result<(), HookError> {
|
pub fn hook_init(library_handle: LibraryHandle) -> Result<(), HookError> {
|
||||||
debug!("Reading hook configuration");
|
debug!("Reading hook configuration");
|
||||||
let config = SaekawaConfig::load().context(ConfigSnafu)?;
|
let config = SaekawaConfig::load().context(ConfigSnafu)?;
|
||||||
|
|
||||||
|
if config.general.auto_update {
|
||||||
|
match self_update(&library_handle) {
|
||||||
|
Ok(should_reboot) => {
|
||||||
|
if should_reboot {
|
||||||
|
info!("Self-update successful. Reloading into new hook...");
|
||||||
|
library_handle.free_and_exit_thread(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Self-update failed: {e:#}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if config.cards.is_empty() {
|
if config.cards.is_empty() {
|
||||||
return Err(HookError::NoCardsError);
|
return Err(HookError::NoCardsError);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user