Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function download(ingest, bucket, provider, granules) {
log.debug(`awaiting lock.proceed in download() bucket: ${bucket}, `
+ `provider: ${JSON.stringify(provider)}, granuleID: ${granules[0].granuleId}`);
const proceed = await lock.proceed(bucket, provider, granules[0].granuleId);
if (!proceed) {
const err = new errors.ResourcesLockedError('Download lock remained in place after multiple tries');
log.error(err);
throw err;
}
const ingestGranule = async (granule) => {
try {
const startTime = Date.now();
const r = await ingest.ingest(granule, bucket);
const endTime = Date.now();
return {
...r,
sync_granule_duration: endTime - startTime
async function download(ingest, bucket, provider, granules) {
const updatedGranules = [];
const proceed = await lock.proceed(bucket, provider, granules[0].granuleId);
if (!proceed) {
const err = new errors.ResourcesLockedError(
'Download lock remained in place after multiple tries'
);
log.error(err);
throw err;
}
for (const g of granules) {
try {
const r = await ingest.ingest(g);
updatedGranules.push(r);
}
catch (e) {
await lock.removeLock(bucket, provider.id, g.granuleId);