Skip to content

Commit

Permalink
Add fault reporting Failure to create MCAP file and Disk full
Browse files Browse the repository at this point in the history
Signed-off-by: Lucia Echevarria <[email protected]>
  • Loading branch information
LuciaEchevarria99 committed Feb 13, 2024
1 parent ea973cb commit a99bb98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ void McapHandler::open_file_nts_()
auto status = mcap_writer_.open(tmp_filename.c_str(), configuration_.mcap_writer_options);
if (!status.ok())
{
logError(
DDSRECORDER_MCAP_HANDLER,
"Failed to open MCAP file " << tmp_filename << " for writing: " << status.message);
throw utils::InitializationException(
STR_ENTRY << "Failed to open MCAP file " << tmp_filename << " for writing: " << status.message);
}
Expand Down
17 changes: 16 additions & 1 deletion thirdparty/mcap/mcap/writer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <lz4hc.h>
#include <zstd.h>
#include <zstd_errors.h>
#include <filesystem>

namespace mcap {

Expand Down Expand Up @@ -53,7 +54,21 @@ void FileWriter::handleWrite(const std::byte* data, uint64_t size) {
assert(file_);
const size_t written = std::fwrite(data, 1, size, file_);
(void)written;
assert(written == size);
if (written != size)
{
#ifdef _WIN32
std::filesystem::space_info space = std::filesystem::space("C:\\");
#else
std::filesystem::space_info space = std::filesystem::space("/");
#endif

if (space.available < size)
{
logError(
DDSRECORDER_MCAP_HANDLER,
"Not enough space available in disk. Space available: " << space.available);
}
}
size_ += size;
}

Expand Down

0 comments on commit a99bb98

Please sign in to comment.