Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async load() {
const {
context,
assets,
assetsDirectory
} = this;
const { logger } = context;
// no need to load assets
if (isEmpty(assets)) return;
this.assetStore = await makeAssetStore(context);
let idArray;
try {
idArray = await this.assetStore.parseAssetsArray(assets);
} catch (err) {
throw new WrapError(err);
}
await Promise.map(idArray, async (assetIdentifier) => {
const downloaded = await fs.pathExists(path.join(assetsDirectory, assetIdentifier));
// need to return the id to the assets array sent back
if (downloaded) return { id: assetIdentifier };
const assetRecord = await this.assetStore.get(assetIdentifier);
logger.info(`loading assets: ${assetIdentifier}`);
await Promise.map(idArray, async (assetIdentifier) => {
const downloaded = await fs.pathExists(path.join(assetsDirectory, assetIdentifier));
// need to return the id to the assets array sent back
if (downloaded) return { id: assetIdentifier };
const assetRecord = await this.assetStore.get(assetIdentifier);
logger.info(`loading assets: ${assetIdentifier}`);
const buff = Buffer.from(assetRecord.blob, 'base64');
return saveAsset(logger, assetsDirectory, assetIdentifier, buff);
});
constructor(context, executionContext) {
this._runner = makeExecutionRunner(context, {
execution: executionContext.job,
processAssignment: executionContext.assignment,
});
this._assets = new Assets(context, executionContext);
this._logger = makeLogger(context, executionContext, 'execution_runner');
this._assignment = executionContext.assignment;
Object.assign(this, executionContext);
this.config = executionContext.job;
this.queue = [];
this.reader = null;
this.slicer = null;
this.reporter = null;
this.queueLength = 10000;