mirror of
https://github.com/beerpiss/saekawa.git
synced 2024-12-18 02:05:52 +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,
|
||||
logging::init_logger,
|
||||
saekawa::{hook_init, hook_release},
|
||||
updater::self_update,
|
||||
};
|
||||
|
||||
#[no_mangle]
|
||||
@ -45,19 +44,7 @@ extern "system" fn DllMain(dll_module: HINSTANCE, call_reason: DWORD, reserved:
|
||||
env!("VERGEN_GIT_BRANCH"),
|
||||
);
|
||||
|
||||
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 let Err(e) = hook_init() {
|
||||
if let Err(e) = hook_init(library_handle) {
|
||||
error!("Failed to initialize hook: {e:#}");
|
||||
}
|
||||
});
|
||||
|
@ -25,11 +25,11 @@ use crate::{
|
||||
config::{ConfigLoadError, SaekawaConfig},
|
||||
helpers::{
|
||||
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,
|
||||
sigscan::{self, CryptoKeys},
|
||||
types::{chuni::UpsertUserAllRequest, ToBatchManual},
|
||||
types::{chuni::UpsertUserAllRequest, ToBatchManual}, updater::self_update,
|
||||
};
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
@ -96,10 +96,24 @@ static UPSERT_USER_ALL_API: OnceLock<String> = 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");
|
||||
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() {
|
||||
return Err(HookError::NoCardsError);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user