in source/lambda/calculateTreehash/index.js [81:113]
async function validateTreehash(s3hash, statusRecord) {
let key = statusRecord.Attributes.fname.S;
let glacierHash = statusRecord.Attributes.sha.S;
if (s3hash !== glacierHash) {
console.error(`ERROR : sha256treehash validation failed : ${key}.\n`);
console.log(`SHA256TreeHash Glacier : ${glacierHash}.`);
console.log(`SHA256TreeHash S3 : ${s3hash}.`);
let retryCount = parseInt(statusRecord.Attributes.rc.N);
if (retryCount < 3) {
console.error(
`ERROR : sha256treehash validation failed for ${key}. Retry: ${retryCount}.\n`
);
await failArchiveAndRetry(statusRecord, key);
return;
} else {
// on 3rd failed calcHash attempt, we log in db
await db.increaseArchiveFailedBytesAndErrorCount("archives-failed", "failedBytes", statusRecord.Attributes.sz.N, "errorCount", "1")
console.error(
`ERROR : sha256treehash validation failed after MULTIPLE retry for ${key}. Manual intervention required.\n`
);
return;
}
}
// now that TreeHash is successfully verified, we start the copy to destination bucket via sending a message to the SQS
// setTimestampNow runs here because we want to mark the time when the validation was completed
await db.setTimestampNow(statusRecord.Attributes.aid.S, "vdt");
await trigger.triggerCopyToDestinationBucket(statusRecord);
}