fix(client): Prevent overwriting auth file on update

This commit is contained in:
hkfires
2025-09-18 23:08:13 +08:00
parent f17ec7ffd8
commit 6bd37b2a2b
2 changed files with 6 additions and 6 deletions

View File

@@ -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

View File

@@ -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 {