unresolved redirects
This commit is contained in:
parent
85e28d66c1
commit
ff601c9037
40
zimmer.js
40
zimmer.js
|
@ -652,7 +652,7 @@ class Item {
|
||||||
|
|
||||||
this.dirEntryOffset = await out.write( chunksToBuffer( chunks ))
|
this.dirEntryOffset = await out.write( chunksToBuffer( chunks ))
|
||||||
log( 'storeDirEntry done', this.dirEntryOffset, this.path )
|
log( 'storeDirEntry done', this.dirEntryOffset, this.path )
|
||||||
return this.saveDirEntryIndex()
|
return await this.saveDirEntryIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveDirEntryIndex ( ) {
|
async saveDirEntryIndex ( ) {
|
||||||
|
@ -663,7 +663,7 @@ class Item {
|
||||||
'INSERT INTO dirEntries (id, offset) VALUES (?,?)',
|
'INSERT INTO dirEntries (id, offset) VALUES (?,?)',
|
||||||
[
|
[
|
||||||
id,
|
id,
|
||||||
Number( this.dirEntryOffset ), // assume dir entries are written close to the beginning
|
this.dirEntryOffset.toString(), // BigInt -> String
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
} catch ( err ) {
|
} catch ( err ) {
|
||||||
|
@ -673,17 +673,18 @@ class Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// class Linktarget
|
// class LinkTarget
|
||||||
//
|
//
|
||||||
class Linktarget extends Item {
|
class LinkTarget extends Item {
|
||||||
constructor ( path, nameSpace, title ) {
|
constructor ( id, path, nameSpace, title ) {
|
||||||
super({
|
super({
|
||||||
|
id,
|
||||||
path,
|
path,
|
||||||
nameSpace,
|
nameSpace,
|
||||||
title,
|
title,
|
||||||
mimeType: LINKTARGET_MIME,
|
mimeType: LINKTARGET_MIME,
|
||||||
})
|
})
|
||||||
log( 'Linktarget', nameSpace, path, this )
|
log( 'LinkTarget', nameSpace, path, this )
|
||||||
}
|
}
|
||||||
|
|
||||||
storeDirEntry () {
|
storeDirEntry () {
|
||||||
|
@ -694,9 +695,10 @@ class Linktarget extends Item {
|
||||||
//
|
//
|
||||||
// class DeletedEntry
|
// class DeletedEntry
|
||||||
//
|
//
|
||||||
class DeletedEntry extends Linktarget {
|
class DeletedEntry extends Item {
|
||||||
constructor ( path, nameSpace, title ) {
|
constructor ( id, path, nameSpace, title ) {
|
||||||
super({
|
super({
|
||||||
|
id,
|
||||||
path,
|
path,
|
||||||
nameSpace,
|
nameSpace,
|
||||||
title,
|
title,
|
||||||
|
@ -704,6 +706,9 @@ class DeletedEntry extends Linktarget {
|
||||||
})
|
})
|
||||||
log( 'DeletedEntry', nameSpace, path, this )
|
log( 'DeletedEntry', nameSpace, path, this )
|
||||||
}
|
}
|
||||||
|
storeDirEntry () {
|
||||||
|
return super.storeDirEntry( 0, 0 )
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1245,17 +1250,18 @@ async function resolveRedirects () {
|
||||||
) AS dstResolved
|
) AS dstResolved
|
||||||
JOIN articles AS src
|
JOIN articles AS src
|
||||||
USING (id)
|
USING (id)
|
||||||
WHERE targetId IS NOT NULL
|
-- WHERE targetId IS NOT NULL
|
||||||
;`)
|
;`)
|
||||||
let row
|
let row
|
||||||
while ( row = await stmt.get() ) {
|
while ( row = await stmt.get() ) {
|
||||||
var nameSpace = row.urlKey[ 0 ]
|
const nameSpace = row.urlKey[ 0 ]
|
||||||
var path = row.urlKey.substr( 1 )
|
const path = row.urlKey.substr( 1 )
|
||||||
var title = ( row.titleKey == row.urlKey ) ? '' : row.titleKey.substr( 1 )
|
const title = ( row.titleKey == row.urlKey ) ? '' : row.titleKey.substr( 1 )
|
||||||
var target = row.targetRow - 1
|
if ( row.targetRow == null ) { // unresolved redirect
|
||||||
|
await new DeletedEntry( row.id, path, nameSpace, title ).process() // Linktarget
|
||||||
await new ResolvedRedirect ( row.id, nameSpace, path, title, target, row.revision )
|
} else {
|
||||||
.process()
|
await new ResolvedRedirect ( row.id, nameSpace, path, title, row.targetRow - 1, row.revision ).process()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return stmt.finalize()
|
return stmt.finalize()
|
||||||
}
|
}
|
||||||
|
@ -1310,7 +1316,7 @@ async function storeUrlIndex () {
|
||||||
rowCb: ( row, index ) => {
|
rowCb: ( row, index ) => {
|
||||||
if ( row.urlKey == mainPage.urlKey )
|
if ( row.urlKey == mainPage.urlKey )
|
||||||
mainPage.index = index
|
mainPage.index = index
|
||||||
return row.offset
|
return BigInt( row.offset )
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user