mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: dupe key errors
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-await-in-loop */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
@@ -14,13 +15,11 @@ module.exports = {
|
|||||||
const { progress } = this;
|
const { progress } = this;
|
||||||
|
|
||||||
await batch.processSortedSet('users:joindate', async (uids) => {
|
await batch.processSortedSet('users:joindate', async (uids) => {
|
||||||
let keys = uids.map(uid => `uid:${uid}:uploads`);
|
const keys = uids.map(uid => `uid:${uid}:uploads`);
|
||||||
const exists = await db.exists(keys);
|
progress.incr(uids.length);
|
||||||
keys = keys.filter((key, idx) => exists[idx]);
|
|
||||||
|
|
||||||
progress.incr(uids.length - keys.length);
|
for (let idx = 0; idx < uids.length; idx++) {
|
||||||
|
const key = keys[idx];
|
||||||
await Promise.all(keys.map(async (key, idx) => {
|
|
||||||
// Rename the paths within
|
// Rename the paths within
|
||||||
let uploads = await db.getSortedSetRangeWithScores(key, 0, -1);
|
let uploads = await db.getSortedSetRangeWithScores(key, 0, -1);
|
||||||
|
|
||||||
@@ -37,9 +36,7 @@ module.exports = {
|
|||||||
// Add uid to the upload's hash object
|
// Add uid to the upload's hash object
|
||||||
uploads = await db.getSortedSetMembers(key);
|
uploads = await db.getSortedSetMembers(key);
|
||||||
await db.setObjectBulk(uploads.map(relativePath => [`upload:${md5(relativePath)}`, { uid: uids[idx] }]));
|
await db.setObjectBulk(uploads.map(relativePath => [`upload:${md5(relativePath)}`, { uid: uids[idx] }]));
|
||||||
|
}
|
||||||
progress.incr();
|
|
||||||
}));
|
|
||||||
}, {
|
}, {
|
||||||
batch: 100,
|
batch: 100,
|
||||||
progress: progress,
|
progress: progress,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
@@ -18,9 +20,9 @@ module.exports = {
|
|||||||
const exists = await db.exists(keys);
|
const exists = await db.exists(keys);
|
||||||
keys = keys.filter((key, idx) => exists[idx]);
|
keys = keys.filter((key, idx) => exists[idx]);
|
||||||
|
|
||||||
progress.incr(pids.length - keys.length);
|
progress.incr(pids.length);
|
||||||
|
|
||||||
await Promise.all(keys.map(async (key) => {
|
for (const key of keys) {
|
||||||
// Rename the paths within
|
// Rename the paths within
|
||||||
let uploads = await db.getSortedSetRangeWithScores(key, 0, -1);
|
let uploads = await db.getSortedSetRangeWithScores(key, 0, -1);
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ module.exports = {
|
|||||||
promises.concat(hashes.map((hash, idx) => db.rename(`upload:${hash}:pids`, `upload:${newHashes[idx]}:pids`)));
|
promises.concat(hashes.map((hash, idx) => db.rename(`upload:${hash}:pids`, `upload:${newHashes[idx]}:pids`)));
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
progress.incr();
|
}
|
||||||
}));
|
|
||||||
}, {
|
}, {
|
||||||
batch: 100,
|
batch: 100,
|
||||||
progress: progress,
|
progress: progress,
|
||||||
|
|||||||
Reference in New Issue
Block a user