Fix Orphaned Scores can crash into real scores with the same ScoreID. #511

This commit is contained in:
zkldi
2021-12-02 10:24:58 +00:00
parent ab22caad16
commit e07f112c5a
+18 -13
View File
@@ -18,19 +18,24 @@ export async function DeoprhanScores() {
let success = 0;
let removed = 0;
await Promise.all(
orphans.map((or) =>
ReprocessOrphan(or, blacklist, logger).then((r) => {
if (r === null) {
removed++;
} else if (r === false) {
failed++;
} else {
success++;
}
})
)
);
for (const or of orphans) {
// We have to await like this to avoid mid-air race conditions,
// where two orphans attempt to deorphan to the same scoreID
// at the same time.
//
// See #511.
// eslint-disable-next-line no-await-in-loop
const r = await ReprocessOrphan(or, blacklist, logger);
if (r === null) {
removed++;
} else if (r === false) {
failed++;
} else {
success++;
}
}
logger.info(`Finished attempting deorphaning.`);