Files
pokemon/scripts/repair-playnite-emulators-db.ps1
T
ginnoirandClaude Opus 4.8 809600a04d feat: ROM-hack dedup, conflict resolution, and vault library_path resync
Catalog cleanup pass across gb/gbc/gba/nds/3ds:
- Standardize nonstandard hack filenames to `Pokemon - <Name> [Hack].<ext>`;
  remove verified byte-identical duplicates (conform-rom-names.sh).
- Resolve 9 version-conflicts via side-by-side emulator comparison
  (resolve-version-conflicts.sh): promote newer builds, keep genuine
  distinct hacks, fix a mislabeled Dark Rising slot (was the Digimon
  crossover "Worlds Collide"), and rebuild Mega Power 5.77 + HeartGold
  Generations v2.0 fresh from their patches.
- Resync 286 vault notes' `library_path` to the real on-disk [Hack] files
  and fix 15 stale platform fields (resync-vault-library-paths.py).
- Regenerate MOC tables + wiki/catalog.json (396 notes).

Also includes pending Playnite PC-hack setup/repair scripts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 14:29:05 -05:00

30 lines
964 B
PowerShell

# Rebuild emulators.db from readable BSON docs (fixes LiteDB page corruption).
$ErrorActionPreference = 'Stop'
Get-Process -Name 'Playnite*' -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 2
$lib = Join-Path $env:LOCALAPPDATA 'Playnite\library'
$src = Join-Path $lib 'emulators.db'
$new = Join-Path $lib 'emulators.db.new'
$bak = Join-Path $lib 'emulators.db.broken'
Add-Type -Path (Join-Path $env:LOCALAPPDATA 'Playnite\LiteDB.dll')
if (Test-Path $new) { Remove-Item -Force $new }
$srcDb = [LiteDB.LiteDatabase]::new("Filename=$src")
$dstDb = [LiteDB.LiteDatabase]::new("Filename=$new")
$srcCol = $srcDb.GetCollection('Emulator')
$dstCol = $dstDb.GetCollection('Emulator')
$n = 0
foreach ($doc in $srcCol.FindAll()) {
$dstCol.Insert($doc) | Out-Null
$n++
}
$srcDb.Dispose()
$dstDb.Dispose()
Move-Item -Force $src $bak
Move-Item -Force $new $src
Write-Host "Rebuilt emulators.db from $n documents."
Write-Host "Old file: $bak"