diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp index 061c398efcdc0ed3d164ed872e1874722bf1893d..8ea2812993bdfe8ab4021534398f0d9fe0fcb05c 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp @@ -135,6 +135,21 @@ namespace daemon { ++memBlockId; } + // If, after the FIFO is finished, we are still in the first block, we are in the presence of a 0-length file. + // This also requires a placeholder. + if (firstBlock) { + currentErrorToCount = "Error_tapeWriteData"; + const char blank[]="This file intentionally left blank: zero-length file cannot be recorded to tape."; + output->write(blank, sizeof(blank)); + m_taskStats.readWriteTime += timer.secs(cta::utils::Timer::resetCounter); + watchdog.notify(sizeof(blank)); + currentErrorToCount = "Error_tapeWriteTrailer"; + output->close(); + currentErrorToCount = ""; + // Possibly failing writes are finished. We can continue this in catch for skip. outside of the loop. + throw Skip("In TapeWriteTask::execute(): inserted a placeholder for zero length file."); + } + //finish the writing of the file on tape //put the trailer currentErrorToCount = "Error_tapeWriteTrailer";