tracker
All repositories: gitoria
1.8 KB
// lib/export.hl — READING THE OLD TRACKER'S MONGO EXPORT (/media/STORAGE/projects/old-tracker/mongo-export/*.jsonl, EJSON, one// document per line): the lines of a file, a Mongo id, the chunk workaround for big files. Used by the one-off tools// tools/migrate.hl (tracker.worldapi.org#2) and tools/old-short-ids.hl (mission 060). Mission 028: was copied into both.import { run } from 'hl:proc'import { readFile, mkDir, exists } from 'hl:fs'static nl = ""static linesOf = (&path) => {raw = readFile(path)if (raw == null) { return [] }out = []for (l of raw.split(nl)) { if (l != '') { out.push(l) } }return out}static oidOf = (&v) => {if (v == null) { return null }if (hlTypeName(v) == 'String') { return v }return v['$oid']}// hl:fs readFile SILENTLY TRUNCATES at 10 MiB (fs.zig hl_fs_read_file, max_size = 1024*1024*10,// no error, no flag — reported as a Hybriel gap, tracker.worldapi.org#2): Show.jsonl (12.4 MB),// Season.jsonl (10.9 MB) and Episode.jsonl (140 MB) are all over it. Worked around WITHOUT// touching the vendored plugin: `split` (coreutils, via hl:proc run — no shell, no JS) cuts the// export into <10 MB chunks in a scratch dir first; each chunk is read whole (well under the cap).static padNum4 = (&n) => {let s = '' + nwhile (s.length < 4) { s = '0' + s }return s}static bigLinesOf = (&path, &chunkDir, &perChunk) => {mkDir(chunkDir, 448)r = run(['split', '-l', '' + perChunk, '-d', '-a', '4', '--additional-suffix=.jsonl', path, chunkDir + '/c_'])if (r == null || r.exit != 0) { hlError('split failed for ' + path) }out = []let idx = 0while (true) {fp = chunkDir + '/c_' + padNum4(&idx) + '.jsonl'if (!exists(fp)) { break }for (l of linesOf(&fp)) { out.push(l) }idx = idx + 1}if (idx == 0) { hlError('no chunks produced for ' + path) }return out}
Branches
Latest commits
- f7bfe90bMove remaining page builders into their topicsmre
- ec54fc35Move show page logic into the shows topicmre
- c1a8d074log: correct timesmre
- 5827eba9log: HM57 merged, HM59 startedmre
- d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
- a404ed75Report HM57 audit, gates and integration notesmre
- 1dcb87a7Use plain declarations for unchanged bindingsmre
- b90395e3log: HM51 mergedmre
- 9888d076Merge hm51-classes: tracker#51 views use Style referencesmre
- 4399bc2fReference remaining component-owned root Style rulesmre
- 9edcc2dflog: #58 live, HM57 startedmre
- 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
- aed12917Reference owned Style rules in genres and searchmre
- 14195720log: HM49B done, HM51 startedmre
- 78ee6b56Move remaining component styles into Style blocksmre
- 7f04de33log: HM49Bmre
- 00616cf3log: #49 batch merged, DP67 startedmre
- d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
- 079f376dMove seven components' styles into Style blocksmre
- 17d66feelog: #58 mergedmre