Fixes in reports (generating a CSV).

Added caching of generated images in mosaico handler.
Various other fixes.
This commit is contained in:
Tomas Bures 2019-04-22 02:41:40 +02:00
parent 055c4c6b51
commit 66702b5edc
39 changed files with 545 additions and 278 deletions

View file

@ -0,0 +1,26 @@
'use strict';
// This implements a simple wrapper around an async function that prevents concurrent execution of the function from two asynchronous chains
// It enforces that the running execution has to complete first before another one is started.
function synchronized(asyncFn) {
let ensurePromise = null;
return async (...args) => {
while (ensurePromise) {
try {
await ensurePromise;
} catch (err) {
}
}
ensurePromise = asyncFn(...args);
try {
return await ensurePromise;
} finally {
ensurePromise = null;
}
}
}
module.exports = synchronized;