TTSキャッシュをパージするスクリプトを実装#5302
Merged
TinyKitten merged 3 commits intodevfrom Feb 17, 2026
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughFirestore の TTS キャッシュ( Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant CLI as CLI\n(find-tts-cache / find-orphaned-tts)
participant Admin as Firebase Admin
participant FS as Firestore
participant GS as Cloud Storage
User->>CLI: 起動 (args: bucket, project, options)
CLI->>Admin: 初期化 (projectId, bucket)
Admin->>FS: Firestore クライアント取得
Admin->>GS: Storage クライアント取得
CLI->>FS: `caches/tts/voices` を一覧取得
CLI->>GS: `caches/tts/...` をページネーションで列挙
CLI->>CLI: Firestore/Storage の差分計算(検出 / マッチ)
CLI->>User: 結果表示(候補一覧、オーファン一覧)
alt --delete フラグ
CLI->>User: 削除確認プロンプト
User->>CLI: 確認応答
CLI->>FS: ドキュメント削除(該当)
CLI->>GS: MP3 ファイル削除(該当)
CLI->>User: 削除結果報告
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@functions/src/cli/find-tts-cache.ts`:
- Around line 150-189: The printed ID and the storage/delete paths currently use
data.id which can be missing or inconsistent; switch to using the Firestore
document id (doc.id) everywhere. In the for-loops that iterate results (where
you have const data = doc.data()), replace references to data.id (the console
log "ID: ..." and the id binding const id: string = data.id and any
storagePathJa/storagePathEn construction) with doc.id (assign const id: string =
doc.id) so display and deletion use the document key consistently.
Contributor
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@functions/src/cli/find-tts-cache.ts`:
- Around line 185-207: The current loop always logs "削除完了" after attempting
deletions even when some deleteResults are rejected; update the logic in the
block handling results (variables: results, deleteResults, labels,
storagePathJa/storagePathEn, doc.ref.delete()) to detect if any Promise in
deleteResults has status 'rejected' and only print a success message for that id
when all succeeded; otherwise print a failure/partial-failure message (including
the per-label warnings already produced) and avoid the misleading "削除完了" line or
change it to "削除完了(部分失敗)" when some deletions failed.
- Around line 32-80: In parseArgs, safeguard all options that consume the next
argv element (notably the --field, --bucket, and --project handling inside the
for loop) by verifying the next token exists and is not another flag (e.g.,
startsWith('--')) before assigning it; if the value is missing or looks like a
flag, print a clear error and process.exit(1). Update the switch cases for
'--field', '--bucket', and '--project' to check const value = args[++i]; if
(!value || value.startsWith('--')) { console.error(...); process.exit(1); }
(preserve the existing validation for 'ssmlJa'/'ssmlEn' in --field).
- Around line 226-231: The current main().catch(...).finally(...) pattern can
overwrite the error exit code; remove the .finally(() => process.exit(0)) and
instead set process.exitCode = 1 inside the catch handler (and avoid calling
process.exit synchronously in catch). Update the catch on main() to log the
error (using err.message) and assign process.exitCode = 1, leaving process
termination to Node.js so cleanups run; ensure no other code calls
process.exit(0) unconditionally after main().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
新機能
チア(保守作業)