jukebox
All repositories: gitoria
1.7 KB
// lib/migrate.hl — KEYS FROM AN EARLIER VERSION. Until JB3 an album key held the folder and "CD 1" stayed in the album name, so one album sat in the database twice. `fixKeys` goes// through the songs of a database made before, folds the disc marker out of the album name, gives the song its disc number and rewrites the album key and the two sort keys// (from the stored fields, no file is read). The state is a one-line file `keys-version` in storage/: the work runs once, and is checked again after every change of the rule.import { readFile, writeFile, exists } from 'hl:fs'import { songsTable, replaceSong } from './db.hl'import { storageRoot } from './util.hl'import { splitDisc, albumKeyOf, discFor, sortKeys } from './albums.hl'static version = '3'static marker = storageRoot + '/keys-version'static needsFix = () => {if (!exists(marker)) { return true }return readFile(marker).trim() != version}// answers how many songs changedstatic fixKeys = () => {let changed = 0rows = []for (s of songsTable.iterate(null, null)) { rows.push(s) }for (s of rows) {parts = splitDisc(s.album)disc = discFor(s.disc == 1 && parts.disc == null ? null : s.disc, parts.disc)key = albumKeyOf(s.albumArtist, parts.name)keys = sortKeys(s.albumArtist, parts.name, disc, s.track == null ? 0 : s.track, s.title)if (key == s.albumKey && parts.name == s.album && disc == s.disc && keys.sortArtist == s.sortArtist && keys.sortAlbum == s.sortAlbum) { continue }rec = {}for (k in s) {if (k != 'id') { rec[k] = s[k] }}rec.album = parts.namerec.albumKey = keyrec.disc = discrec.sortArtist = keys.sortArtistrec.sortAlbum = keys.sortAlbumreplaceSong(s.id, rec)changed = changed + 1}writeFile(marker, version, 420)return changed}
Branches
Latest commits
- 5838d6c7|||PR STATUS: #22 pending decision, PR-only rulemre
- 29d2029cRecords: PR-only rule (Kunibert)mre
- adacb0abRecords: neutral ticket rule, #22 decision recordedmre
- b2d6f121Records: #308 hold liftedmre
- 7ab67533Records: day39 on hold (hybriel#308)mre
- 22f21739Records: note rebase before mergemre
- f7368ea3Records: mission 011 day39, waits for lisbethmre
- 9515d2cdRecords: jb20 livemre
- 019f6601ui gate: comment names the open bug components#27 (workaround, not fixed)mre
- 277a2722README: provenance linemre
- 4169ca6aREADME: sync pinmre
- a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mre
- f7936c20Lists keep their scroll position across a reload (jukebox#20): per-list offsets in storage/ui.json, gate jb20mre
- d67906devirtual-list and icons from components.hybriel e5b98ec (centerId, scrollTop, onScroll)mre
- df7920ceRecords: R3 startedmre
- 0549f038Mission 010: jb20 livemre
- 273494e2STATUS rewrittenmre
- 227c9b96Records: jb19 livemre
- 9f365376README: the bar's controls (jb19)mre
- d18851fdjb19: pressed switches look different (whole selector), queue column cannot widen past the panel, gates follow the new bar (jb3, jb11, jb15)mre