From 6bd37b2a2bd9029c87e57ea90c60360ed8e66dd6 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:08:13 +0800 Subject: [PATCH] fix(client): Prevent overwriting auth file on update --- internal/client/gemini-web_client.go | 7 +++---- internal/client/qwen_client.go | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/client/gemini-web_client.go b/internal/client/gemini-web_client.go index ea002380..3f7e0535 100644 --- a/internal/client/gemini-web_client.go +++ b/internal/client/gemini-web_client.go @@ -80,10 +80,9 @@ func (c *GeminiWebClient) unregisterClient(reason interfaces.UnregisterReason) { util.RemoveCookieSnapshots(c.tokenFilePath) } case interfaces.UnregisterReasonAuthFileUpdated: - if c.snapshotManager != nil { - if err := c.snapshotManager.Persist(); err != nil { - log.Errorf("Failed to persist Gemini Web cookies for %s: %v", filepath.Base(c.tokenFilePath), err) - } + if c.snapshotManager != nil && c.tokenFilePath != "" { + log.Debugf("skipping Gemini Web snapshot flush because auth file was updated: %s", filepath.Base(c.tokenFilePath)) + util.RemoveCookieSnapshots(c.tokenFilePath) } default: // Flush cookie snapshot to main token file and remove snapshot diff --git a/internal/client/qwen_client.go b/internal/client/qwen_client.go index a6c4e156..74e2416a 100644 --- a/internal/client/qwen_client.go +++ b/internal/client/qwen_client.go @@ -525,8 +525,9 @@ func (c *QwenClient) unregisterClient(reason interfaces.UnregisterReason) { util.RemoveCookieSnapshots(c.tokenFilePath) } case interfaces.UnregisterReasonAuthFileUpdated: - if err := c.snapshotManager.Persist(); err != nil { - log.Errorf("Failed to persist Qwen cookies for %s: %v", filepath.Base(c.tokenFilePath), err) + if c.tokenFilePath != "" { + log.Debugf("skipping Qwen snapshot flush because auth file was updated: %s", filepath.Base(c.tokenFilePath)) + util.RemoveCookieSnapshots(c.tokenFilePath) } case interfaces.UnregisterReasonShutdown, interfaces.UnregisterReasonReload: if err := c.snapshotManager.Flush(); err != nil {