mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-04-25 15:36:31 -05:00
Run all update operations in parallel
This commit is contained in:
parent
fbdea0f3c2
commit
441c0b262f
|
|
@ -4,6 +4,9 @@ import mkdirp from 'mkdirp';
|
|||
import jsonpath from 'jsonpath';
|
||||
import get from 'lodash/get.js';
|
||||
import set from 'lodash/set.js';
|
||||
import pLimit from 'p-limit';
|
||||
|
||||
const limit = pLimit(1);
|
||||
|
||||
function makeArray(value) {
|
||||
return Array.isArray(value) ? value : [value];
|
||||
|
|
@ -55,6 +58,12 @@ export class LocalizationProcessor {
|
|||
}
|
||||
|
||||
async updateLocalizations(data) {
|
||||
// We're reading, modifying, and writing back to the same file,
|
||||
// so we have to make sure the whole operation is atomic.
|
||||
return limit(() => this._updateLocalizations(data));
|
||||
}
|
||||
|
||||
async _updateLocalizations(data) {
|
||||
let localizations = await this.readData();
|
||||
|
||||
for (let { path, value } of this.dataIterations(data)) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export async function update(config = 'default') {
|
|||
|
||||
let settings = configs[config];
|
||||
|
||||
for (let updater of updaters()) {
|
||||
await Promise.all(updaters().map(async updater => {
|
||||
updater.settings = settings;
|
||||
try {
|
||||
await updater.updateIfNeeded();
|
||||
|
|
@ -51,7 +51,7 @@ export async function update(config = 'default') {
|
|||
console.error(e);
|
||||
Sentry.captureException(e);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
if (canSync()) {
|
||||
await ImageProcessor.onIdle();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user