File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments