Skip to content

Commit 9639713

Browse files
committed
Do not flush a read series that did not do any IO yet
1 parent 0ecd76c commit 9639713

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

src/Series.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,18 +3119,25 @@ namespace internal
31193119
{
31203120
this->m_sharedStatefulIterator->close();
31213121
}
3122-
/*
3123-
* Scenario: A user calls `Series::flush()` but does not check for
3124-
* thrown exceptions. The exception will propagate further up,
3125-
* usually thereby popping the stack frame that holds the `Series`
3126-
* object. `Series::~Series()` will run. This check avoids that the
3127-
* `Series` is needlessly flushed a second time. Otherwise, error
3128-
* messages can get very confusing.
3129-
*/
31303122
Series impl;
31313123
impl.setData({this, [](auto const *) {}});
3132-
if (auto IOHandler = impl.IOHandler();
3133-
IOHandler && IOHandler->m_lastFlushSuccessful)
3124+
if (auto IOHandler = impl.IOHandler(); IOHandler &&
3125+
/*
3126+
* Scenario: A user calls `Series::flush()` but does not check for
3127+
* thrown exceptions. The exception will propagate further up,
3128+
* usually thereby popping the stack frame that holds the `Series`
3129+
* object. `Series::~Series()` will run. This check avoids that the
3130+
* `Series` is needlessly flushed a second time. Otherwise, error
3131+
* messages can get very confusing.
3132+
*/
3133+
3134+
IOHandler->m_lastFlushSuccessful &&
3135+
/*
3136+
* If a read-only Series is opened without any backend access, then
3137+
* don't go there now. Just peacefully close.
3138+
*/
3139+
!(access::readOnly(IOHandler->m_frontendAccess) &&
3140+
!(*this)->m_writable.written))
31343141
{
31353142
impl.flush();
31363143
/*

0 commit comments

Comments
 (0)