async function handler()

in source/lambda/copyChunk/index.js [33:65]


async function handler(event, context, callback){
    let request = JSON.parse(event.Records[0].body)
    let {
        glacierRetrievalStatus,
        uploadId,
        key,
        partNo,
        startByte,
        endByte
    } = request

    let jobId = glacierRetrievalStatus.JobId;
    let archiveId = glacierRetrievalStatus.ArchiveId;
    

    // If sgt is present, it means that copy is already done 
    // but the calcHash failed (either single or multipart copy). 
    let statusRecord = await db.getStatusRecord(archiveId);
    statusRecord.Attributes = statusRecord.Item;
    let archiveSize = statusRecord.Attributes.sz.N
    if (statusRecord.Attributes.sgt && statusRecord.Attributes.sgt.S) {
        console.log(`${key} : upload has already been processed`)
        await trigger.calcHash(statusRecord)
        return
    }

    //singleChunk has no uploadId
    if (uploadId == null){
        await singleChunkCopy(glacierRetrievalStatus, jobId, archiveId, key, statusRecord, archiveSize, callback)
    } else {
        await multiChunkCopy(uploadId, jobId, archiveId, key, partNo, startByte, endByte, archiveSize, callback)
    }
}