Skip to content

Commit c38c82a

Browse files
committed
Accept undefined dataset as long as no chunks are written yet
Just ignore and skip the component in that case
1 parent 0723a59 commit c38c82a

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/RecordComponent.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,21 @@ void RecordComponent::flush(
242242
*/
243243
if (!rc.m_dataset.has_value())
244244
{
245-
throw error::WrongAPIUsage(
246-
"[RecordComponent] Must specify dataset type and extent before "
247-
"flushing (see RecordComponent::resetDataset()).");
245+
// The check for !written() is technically not needed, just
246+
// defensive programming against internal bugs that go on us.
247+
if (!written() && rc.m_chunks.empty())
248+
{
249+
// No data written yet, just accessed the object so far without
250+
// doing anything
251+
// Just do nothing and skip this record component.
252+
return;
253+
}
254+
else
255+
{
256+
throw error::WrongAPIUsage(
257+
"[RecordComponent] Must specify dataset type and extent "
258+
"before flushing (see RecordComponent::resetDataset()).");
259+
}
248260
}
249261
if (!written())
250262
{

src/backend/PatchRecordComponent.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,22 @@ void PatchRecordComponent::flush(
104104
{
105105
if (!rc.m_dataset.has_value())
106106
{
107-
throw error::WrongAPIUsage(
108-
"[PatchRecordComponent] Must specify dataset type and extent "
109-
"before "
110-
"flushing (see RecordComponent::resetDataset()).");
107+
// The check for !written() is technically not needed, just
108+
// defensive programming against internal bugs that go on us.
109+
if (!written() && rc.m_chunks.empty())
110+
{
111+
// No data written yet, just accessed the object so far without
112+
// doing anything
113+
// Just do nothing and skip this record component.
114+
return;
115+
}
116+
else
117+
{
118+
throw error::WrongAPIUsage(
119+
"[PatchRecordComponent] Must specify dataset type and "
120+
"extent before flushing (see "
121+
"RecordComponent::resetDataset()).");
122+
}
111123
}
112124
if (!written())
113125
{

0 commit comments

Comments
 (0)