zimlib v4.0.4 compatibility minor
This commit is contained in:
parent
1618900aaf
commit
e65ae2b25b
44
zimmer.js
44
zimmer.js
|
@ -454,21 +454,16 @@ class ClusterPool {
|
||||||
|
|
||||||
async save ( cluster ) {
|
async save ( cluster ) {
|
||||||
const data = await cluster.getData()
|
const data = await cluster.getData()
|
||||||
let offset
|
const row = [ cluster.id ]
|
||||||
if ( argv.zimlib4Fix ) { // zimlib4Fix stores clusters in separate files
|
if ( ! argv.zimlib4Fix ) {
|
||||||
|
const offset = await out.write( data )
|
||||||
|
row.push( offset.toString() ) // convert BigInt to String
|
||||||
|
} else { // zimlib4Fix stores clusters in separate files
|
||||||
await fs.outputFile( osPath.join( this.savePrefix, `${cluster.id}` ), data )
|
await fs.outputFile( osPath.join( this.savePrefix, `${cluster.id}` ), data )
|
||||||
} else {
|
row.push( data.length ) // cluster sizes instead of offsets
|
||||||
offset = await out.write( data )
|
|
||||||
}
|
}
|
||||||
await wikiDb.run(
|
await wikiDb.run( 'INSERT INTO clusters ( id, offset ) VALUES ( ?,? )', row )
|
||||||
'INSERT INTO clusters ( id, offset ) VALUES ( ?,? )',
|
log( 'Cluster saved', row )
|
||||||
[
|
|
||||||
cluster.id,
|
|
||||||
( argv.zimlib4Fix ? data.length : offset ).toString() // zimlib4Fix stores cluster sizes instead of offsets
|
|
||||||
]
|
|
||||||
)
|
|
||||||
log( 'Cluster saved', cluster.id, data.length )
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async append ( mimeType, data, path /* for debugging */ ) {
|
async append ( mimeType, data, path /* for debugging */ ) {
|
||||||
|
@ -514,7 +509,16 @@ class ClusterPool {
|
||||||
async storeIndex () {
|
async storeIndex () {
|
||||||
const byteLength = 8
|
const byteLength = 8
|
||||||
const count = header.clusterCount
|
const count = header.clusterCount
|
||||||
let offsetZimlib4 = await out.write( Buffer.alloc( 0 )) + BigInt( count * byteLength ) // zimlib4Fix
|
let rowCb = ( row, index ) => BigInt( row.offset )
|
||||||
|
|
||||||
|
if ( argv.zimlib4Fix ) {
|
||||||
|
let offsetZimlib4 = await out.write( Buffer.alloc( 0 )) + BigInt( count * byteLength )
|
||||||
|
rowCb = ( row, index ) => {
|
||||||
|
const val = offsetZimlib4
|
||||||
|
offsetZimlib4 += BigInt( row.offset )
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header.clusterPtrPos = await saveIndex ({
|
header.clusterPtrPos = await saveIndex ({
|
||||||
query:`
|
query:`
|
||||||
|
@ -523,20 +527,10 @@ class ClusterPool {
|
||||||
FROM clusters
|
FROM clusters
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
;`,
|
;`,
|
||||||
rowField: 'size',
|
|
||||||
byteLength,
|
byteLength,
|
||||||
count,
|
count,
|
||||||
logPrefix: 'storeClusterIndex',
|
logPrefix: 'storeClusterIndex',
|
||||||
rowCb: ( row, index ) => {
|
rowCb,
|
||||||
const offset = BigInt( row.offset )
|
|
||||||
if ( ! argv.zimlib4Fix ) {
|
|
||||||
return offset
|
|
||||||
} else { // zimlib4Fix stores cluster sizes instead of offsets
|
|
||||||
const val = offsetZimlib4
|
|
||||||
offsetZimlib4 += offset
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user