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
Some checks failed
Release Binaries / release (push) Has been cancelled
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user