fix: ensure all API requests use user ID and fix missing data migration for existing users
Some checks failed
Release Binaries / release (push) Has been cancelled

This commit is contained in:
Gemini AI
2025-12-29 01:58:15 +04:00
Unverified
parent 39d1e03785
commit 57720e6c5b
5 changed files with 182 additions and 124 deletions

View File

@@ -124,6 +124,26 @@ export function ensureDefaultUsers(): UserRecord {
roman.updatedAt = nowIso()
writeStore(store)
}
// NEW: Check if roman needs data migration (e.g. if he was created before migration logic was robust)
const userDir = getUserDir(roman.id)
const configPath = join(userDir, "config.json")
let needsMigration = !existsSync(configPath)
if (!needsMigration) {
try {
const config = JSON.parse(readFileSync(configPath, "utf-8"))
if (!config.recentFolders || config.recentFolders.length === 0) {
needsMigration = true
}
} catch (e) {
needsMigration = true
}
}
if (needsMigration) {
console.log(`[UserStore] Roman exists but seems to have missing data. Triggering migration to ${userDir}...`)
migrateLegacyData(userDir)
}
}
if (store.users.length > 0) {