mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-14 18:47:32 +01:00
fix: upgrade script to handle topics that were already pruned
get the tid from the zsets intead of topic hash since its gone already
This commit is contained in:
@@ -17,10 +17,16 @@ module.exports = {
|
|||||||
async function cleanupSet(setName) {
|
async function cleanupSet(setName) {
|
||||||
const tidsToRemove = [];
|
const tidsToRemove = [];
|
||||||
await batch.processSortedSet(setName, async (tids) => {
|
await batch.processSortedSet(setName, async (tids) => {
|
||||||
const topicData = await db.getObjectsFields(tids.map(tid => `topic:${tid}`), ['tid', 'cid']);
|
const topicData = await db.getObjectsFields(tids.map(tid => `topic:${tid}`), ['cid']);
|
||||||
|
topicData.forEach((t, index) => {
|
||||||
|
if (t) {
|
||||||
|
t.tid = tids[index];
|
||||||
|
}
|
||||||
|
});
|
||||||
const batchTids = topicData.filter(
|
const batchTids = topicData.filter(
|
||||||
t => t && (!t.cid || !utils.isNumber(t.cid) || t.cid === -1)
|
t => t && (!t.cid || !utils.isNumber(t.cid) || t.cid === -1)
|
||||||
).map(t => t.tid);
|
).map(t => t.tid);
|
||||||
|
|
||||||
tidsToRemove.push(...batchTids);
|
tidsToRemove.push(...batchTids);
|
||||||
progress.incr(tids.length);
|
progress.incr(tids.length);
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user