Skip to content

Commit

Permalink
Accept undefined dataset as long as no chunks are written yet
Browse files Browse the repository at this point in the history
Just ignore and skip the component in that case
  • Loading branch information
franzpoeschel committed Apr 12, 2023
1 parent 0723a59 commit c38c82a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
18 changes: 15 additions & 3 deletions src/RecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,21 @@ void RecordComponent::flush(
*/
if (!rc.m_dataset.has_value())
{
throw error::WrongAPIUsage(
"[RecordComponent] Must specify dataset type and extent before "
"flushing (see RecordComponent::resetDataset()).");
// The check for !written() is technically not needed, just
// defensive programming against internal bugs that go on us.
if (!written() && rc.m_chunks.empty())
{
// No data written yet, just accessed the object so far without
// doing anything
// Just do nothing and skip this record component.
return;
}
else
{
throw error::WrongAPIUsage(
"[RecordComponent] Must specify dataset type and extent "
"before flushing (see RecordComponent::resetDataset()).");
}
}
if (!written())
{
Expand Down
20 changes: 16 additions & 4 deletions src/backend/PatchRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,22 @@ void PatchRecordComponent::flush(
{
if (!rc.m_dataset.has_value())
{
throw error::WrongAPIUsage(
"[PatchRecordComponent] Must specify dataset type and extent "
"before "
"flushing (see RecordComponent::resetDataset()).");
// The check for !written() is technically not needed, just
// defensive programming against internal bugs that go on us.
if (!written() && rc.m_chunks.empty())
{
// No data written yet, just accessed the object so far without
// doing anything
// Just do nothing and skip this record component.
return;
}
else
{
throw error::WrongAPIUsage(
"[PatchRecordComponent] Must specify dataset type and "
"extent before flushing (see "
"RecordComponent::resetDataset()).");
}
}
if (!written())
{
Expand Down

0 comments on commit c38c82a

Please sign in to comment.