Skip to content

Commit b78091e

Browse files
authored
fix: token watcher
1 parent 4708859 commit b78091e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

clients/openframe-chat/src-tauri/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ fn apply_config(app: &tauri::AppHandle, cfg: config_reader::AppConfig) {
149149
if let (Some(path), Some(secret)) = (cfg.token_path, cfg.secret) {
150150
if let Some(state) = app.try_state::<TokenState>() {
151151
let mut started = state.started.lock().unwrap();
152-
if !*started {
153-
TokenWatcher::start(path, secret, app.clone(), state.current_token.clone());
152+
if !*started
153+
&& TokenWatcher::start(path, secret, app.clone(), state.current_token.clone())
154+
{
154155
*started = true;
155156
log::info!("token watcher initialized");
156157
}

clients/openframe-chat/src-tauri/src/token_watcher.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ impl TokenWatcher {
3333
secret: String,
3434
app_handle: AppHandle,
3535
current_token: Arc<Mutex<Option<String>>>,
36-
) {
36+
) -> bool {
3737
let decryption_service = match TokenDecryptionService::new(secret) {
3838
Ok(service) => service,
3939
Err(e) => {
4040
log::error!("token watcher: failed to create decryption service: {}", e);
41-
return;
41+
return false;
4242
}
4343
};
4444

@@ -55,6 +55,8 @@ impl TokenWatcher {
5555
std::thread::sleep(Duration::from_secs(5));
5656
}
5757
});
58+
59+
true
5860
}
5961

6062
/// Reads the encrypted token from file, decrypts it, and returns it

0 commit comments

Comments
 (0)