connect()

in fileProcessingUtils.js [46:86]


	connect(setRegion, function(dynamoDB, s3) {
		let processing = true;
		let params = {
			Bucket : bucket,
			Prefix : prefix
		};
		async.whilst(function(test_cb) {
			test_cb(null, processing);
		}, function(whilstCallback) {
			s3.listObjectsV2(params, function(err, data) {
				if (err) {
					whilstCallback(err);
				} else {
					// for each returned object, check the filter regex
					async.map(data.Contents, function(item, mapCallback) {
						if ((matcher && matcher.test(item.Key)) || !matcher) {
							filesProcessed++;
							console.log("Requesting reprocess of " + bucket + "/" + item.Key);
							common.reprocessFile(dynamoDB, s3, setRegion, bucket + "/" + item.Key, mapCallback);
						}
					}, function(err) {
						if (err) {
							whilstCallback(err)
						} else {
							if (data.IsTruncated === true) {
								params.ContinuationToken = data.NextContinuationToken;
							} else {
								// data wasn't truncated, so we have all the
								// results
								processing = false;
							}

							whilstCallback();
						}
					});
				}
			});
		}, function(err) {
			callback(err, filesProcessed);
		});
	});