fix(cloud-sync): finish active dictation and meeting recording before switching to another account's database
Signing in as a different account (e.g. while the previous one was still waiting on an offline restore) swapped the database under a live recording, so its final save and audio upload went into the new account. The sign-out capture shutdown now also runs whenever the open database belongs to another user.
This commit is contained in:
parent
69c4307eee
commit
c3ca95d20f
2 changed files with 59 additions and 12 deletions
|
|
@ -395,6 +395,12 @@ class CloudSyncService extends EventEmitter {
|
|||
previous.dispose()
|
||||
await previous.whenIdle(ENGINE_STOP_TIMEOUT_MS)
|
||||
}
|
||||
// 다른 계정 DB 로 바뀌기 전에 진행 중인 받아쓰기·회의를 지금 DB 에 끝낸다. 그대로 두면 정지 시점의
|
||||
// 저장·업로드가 새 계정 DB·저장소로 들어갔다(오프라인 복원 대기 중 다른 계정으로 로그인한 경우).
|
||||
const openUserId = getCurrentUserId()
|
||||
if (openUserId !== null && openUserId !== userId) {
|
||||
await this._stopActiveCapture(`auth:${opts.reason}`)
|
||||
}
|
||||
this._session = session
|
||||
this._offlineUserId = null
|
||||
|
||||
|
|
@ -523,22 +529,18 @@ class CloudSyncService extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
private async _runSignOut(options: { unregister: boolean }): Promise<void> {
|
||||
// 오프라인 복원 대기도 끝낸다 — 로그아웃한 계정의 토큰으로 다시 복원하지 않게.
|
||||
this._cancelRestoreRetry()
|
||||
this._offlineUserId = null
|
||||
|
||||
// 1) 활성 녹음/세션 강제 종료 (DB close 전에 flush 기회 제공)
|
||||
/** 진행 중인 받아쓰기·회의 녹음·자막을 지금 열린 DB 에 끝낸다(DB 를 닫거나 바꾸기 전). */
|
||||
private async _stopActiveCapture(tag: string): Promise<void> {
|
||||
try {
|
||||
const { getVoiceModeService } = await import('./VoiceModeService')
|
||||
const voiceMode = getVoiceModeService()
|
||||
if (voiceMode.isActive) {
|
||||
voiceMode.cancelSession()
|
||||
logger.info('[signOut] VoiceMode active session cancelled')
|
||||
logger.info(`[${tag}] VoiceMode active session cancelled`)
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
`[signOut] VoiceMode cancel failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
`[${tag}] VoiceMode cancel failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -547,11 +549,11 @@ class CloudSyncService extends EventEmitter {
|
|||
const meetingMode = getMeetingModeService()
|
||||
if (meetingMode.isMeetingModeActive()) {
|
||||
await meetingMode.stopRecording()
|
||||
logger.info('[signOut] MeetingMode recording stopped')
|
||||
logger.info(`[${tag}] MeetingMode recording stopped`)
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
`[signOut] MeetingMode stop failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
`[${tag}] MeetingMode stop failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -561,9 +563,18 @@ class CloudSyncService extends EventEmitter {
|
|||
await captionService.stop()
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
`[signOut] Caption stop failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
`[${tag}] Caption stop failed: ${err instanceof Error ? err.message : String(err)}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private async _runSignOut(options: { unregister: boolean }): Promise<void> {
|
||||
// 오프라인 복원 대기도 끝낸다 — 로그아웃한 계정의 토큰으로 다시 복원하지 않게.
|
||||
this._cancelRestoreRetry()
|
||||
this._offlineUserId = null
|
||||
|
||||
// 1) 활성 녹음/세션 강제 종료 (DB close 전에 flush 기회 제공)
|
||||
await this._stopActiveCapture('signOut')
|
||||
|
||||
// 2) Realtime 구독·주기 작업 종료, 엔진 해제
|
||||
await this.stopRealtime()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue