fix: dupe key errors

isekai-main
Barış Soner Uşaklı 3 years ago
parent b47ca86db5
commit 770fcd9ea8

@ -1,3 +1,4 @@
/* eslint-disable no-await-in-loop */
'use strict';
const crypto = require('crypto');
@ -14,13 +15,11 @@ module.exports = {
const { progress } = this;
await batch.processSortedSet('users:joindate', async (uids) => {
let keys = uids.map(uid => `uid:${uid}:uploads`);
const exists = await db.exists(keys);
keys = keys.filter((key, idx) => exists[idx]);
const keys = uids.map(uid => `uid:${uid}:uploads`);
progress.incr(uids.length);
progress.incr(uids.length - keys.length);
await Promise.all(keys.map(async (key, idx) => {
for (let idx = 0; idx < uids.length; idx++) {
const key = keys[idx];
// Rename the paths within
let uploads = await db.getSortedSetRangeWithScores(key, 0, -1);
@ -37,9 +36,7 @@ module.exports = {
// Add uid to the upload's hash object
uploads = await db.getSortedSetMembers(key);
await db.setObjectBulk(uploads.map(relativePath => [`upload:${md5(relativePath)}`, { uid: uids[idx] }]));
progress.incr();
}));
}
}, {
batch: 100,
progress: progress,

@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */
'use strict';
const crypto = require('crypto');
@ -18,9 +20,9 @@ module.exports = {
const exists = await db.exists(keys);
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
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`)));
await Promise.all(promises);
progress.incr();
}));
}
}, {
batch: 100,
progress: progress,

Loading…
Cancel
Save