Commit 1d31d166 authored by Michael Davis's avatar Michael Davis
Browse files

cta/CTA#584 Verifies checksum before writing disk replica

Writing the disk replica will fail if the checksum of the file read
from tape does not match the checksum in the CTA catalogue.
parent 6ab791f5
......@@ -127,11 +127,7 @@ public:
// end of file. append() also protects against reading too big tape blocks.
while (mb->m_payload.append(*rf)) {
if(isVerifyOnly) {
// Normally, the checksum is calculated in DiskWriteTask::execute(). In verification-only mode, there is no
// write to disk. As we need to validate the checksum, we calculate it here.
checksum_adler32 = mb->m_payload.adler32(checksum_adler32);
checksum_adler32 = mb->m_payload.adler32(checksum_adler32);
} catch (const cta::exception::EndOfFile&) {
// append() signaled the end of the file.
......@@ -151,17 +147,18 @@ public:
// Don't write the file to disk
// If we reached the end of the file, validate the checksum (throws an exception on bad checksum)
if(!stillReading) {
tapeReadChecksum.insert(cta::checksum::ADLER32, checksum_adler32);
// Pass the block to the disk write task
localStats.waitReportingTime += timer.secs(cta::utils::Timer::resetCounter);
} //end of while(stillReading)
if(isVerifyOnly) {
tapeReadChecksum.insert(cta::checksum::ADLER32, checksum_adler32);
// we have to signal the end of the tape read to the disk write task.
// We have to signal the end of the tape read to the disk write task.
// Log the successful transfer
localStats.totalTime = localTime.secs();
......@@ -195,19 +192,18 @@ public:
if(isVerifyOnly) {
params.add("checksumType", "ADLER32")
.add("checksumValue", cta::checksum::ChecksumBlob::ByteArrayToHex(;
.add("checksumType", "ADLER32")
.add("checksumValue", cta::checksum::ChecksumBlob::ByteArrayToHex(;
lc.log(cta::log::INFO, "File successfully read from tape");
// Add the local counts to the session's
} //end of try
catch (const cta::exception::Exception & ex) {
//we end up there because :
//-- openReadFile brought us here (cant position to the file)
// We end up here because:
//-- openReadFile brought us here (can't position to the file)
//-- m_payload.append brought us here (error while reading the file)
//-- Checksum validation failed (after reading the last block from tape)
// Record the error in the watchdog
if (currentErrorToCount.size()) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment