From bf9e05f9c896803671203a2316e66f7dbaf30d5a Mon Sep 17 00:00:00 2001 From: Nebhay Date: Wed, 25 Feb 2026 09:13:06 +0000 Subject: [PATCH 1/4] Delete twitch_token.json when disconnecting Twitch platform Previously, disconnecting Twitch would remove credentials from config.toml and shut down the adapter, but the token file at instance_dir/twitch_token.json was left behind. This adds cleanup of the token file during disconnect. --- src/api/messaging.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/messaging.rs b/src/api/messaging.rs index d0dd973aa..39e69e2d4 100644 --- a/src/api/messaging.rs +++ b/src/api/messaging.rs @@ -243,6 +243,18 @@ pub(super) async fn disconnect_platform( tracing::warn!(%error, platform = %platform, "failed to shut down adapter during disconnect"); } + if platform == "twitch" { + let instance_dir = state.instance_dir.load(); + let token_path = instance_dir.join("twitch_token.json"); + if token_path.exists() { + if let Err(error) = tokio::fs::remove_file(&token_path).await { + tracing::warn!(%error, path = %token_path.display(), "failed to delete twitch token file"); + } else { + tracing::info!(path = %token_path.display(), "twitch token file deleted"); + } + } + } + tracing::info!(platform = %platform, "platform disconnected via API"); Ok(Json(serde_json::json!({ From fd928989152725d2abd67f8b84500e6773600479 Mon Sep 17 00:00:00 2001 From: Nebhay Date: Wed, 25 Feb 2026 09:32:16 +0000 Subject: [PATCH 2/4] Update src/api/messaging.rs Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com> --- src/api/messaging.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/api/messaging.rs b/src/api/messaging.rs index 39e69e2d4..72d6601f1 100644 --- a/src/api/messaging.rs +++ b/src/api/messaging.rs @@ -246,12 +246,10 @@ pub(super) async fn disconnect_platform( if platform == "twitch" { let instance_dir = state.instance_dir.load(); let token_path = instance_dir.join("twitch_token.json"); - if token_path.exists() { - if let Err(error) = tokio::fs::remove_file(&token_path).await { - tracing::warn!(%error, path = %token_path.display(), "failed to delete twitch token file"); - } else { - tracing::info!(path = %token_path.display(), "twitch token file deleted"); - } + match tokio::fs::remove_file(&token_path).await { + Ok(()) => tracing::info!(path = %token_path.display(), "twitch token file deleted"), + Err(error) if error.kind() == std::io::ErrorKind::NotFound => {} + Err(error) => tracing::warn!(%error, path = %token_path.display(), "failed to delete twitch token file"), } } From 6a4dedd4ef67df3b8bd70a19724b14ad91b0915f Mon Sep 17 00:00:00 2001 From: Nebhay Date: Wed, 25 Feb 2026 11:31:05 +0000 Subject: [PATCH 3/4] formatting Update src/api/messaging.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/api/messaging.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/api/messaging.rs b/src/api/messaging.rs index 72d6601f1..c1e0f73b6 100644 --- a/src/api/messaging.rs +++ b/src/api/messaging.rs @@ -247,9 +247,18 @@ pub(super) async fn disconnect_platform( let instance_dir = state.instance_dir.load(); let token_path = instance_dir.join("twitch_token.json"); match tokio::fs::remove_file(&token_path).await { - Ok(()) => tracing::info!(path = %token_path.display(), "twitch token file deleted"), + Ok(()) => { + tracing::info!(path = %token_path.display(), "twitch token file deleted"); + } Err(error) if error.kind() == std::io::ErrorKind::NotFound => {} - Err(error) => tracing::warn!(%error, path = %token_path.display(), "failed to delete twitch token file"), + Err(error) => { + tracing::warn!( + %error, + path = %token_path.display(), + "failed to delete twitch token file" + ); + } + } } } From 72c80aba3a22b1de947b749929380700daf87afe Mon Sep 17 00:00:00 2001 From: Nebhay Date: Wed, 25 Feb 2026 11:54:07 +0000 Subject: [PATCH 4/4] fix bad coderabbit formatting --- src/api/messaging.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/messaging.rs b/src/api/messaging.rs index c1e0f73b6..7198436a5 100644 --- a/src/api/messaging.rs +++ b/src/api/messaging.rs @@ -259,7 +259,6 @@ pub(super) async fn disconnect_platform( ); } } - } } tracing::info!(platform = %platform, "platform disconnected via API");