Skip to content

Commit 8154c29

Browse files
committed
Fixes to the dirty/dirtyRecursive logic
1 parent a95923c commit 8154c29

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/CustomHierarchy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,11 @@ void CustomHierarchy::flush_internal(
634634
{
635635
dataset.flush(name, flushParams, /* set_defaults = */ false);
636636
}
637-
setDirty(false);
637+
if (flushParams.flushLevel != FlushLevel::SkeletonOnly &&
638+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles)
639+
{
640+
setDirty(false);
641+
}
638642
}
639643

640644
void CustomHierarchy::flush(

src/Iteration.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,13 @@ void Iteration::flushIteration(internal::FlushParams const &flushParams)
364364
s.setParticlesPath(particlesPaths);
365365
}
366366

367-
if (access::write(IOHandler()->m_frontendAccess))
368-
{
369-
flushAttributes(flushParams);
370-
}
371-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
367+
if (flushParams.flushLevel != FlushLevel::SkeletonOnly &&
368+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles)
372369
{
370+
if (access::write(IOHandler()->m_frontendAccess))
371+
{
372+
flushAttributes(flushParams);
373+
}
373374
setDirty(false);
374375
meshes.setDirty(false);
375376
particles.setDirty(false);

src/Series.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,13 @@ void Series::flushFileBased(
14121412
case Access::READ_WRITE:
14131413
case Access::CREATE:
14141414
case Access::APPEND: {
1415-
bool allDirty = dirty();
1415+
bool const allDirty = dirty();
14161416
for (auto it = begin; it != end; ++it)
14171417
{
1418+
/* reset the dirty bit for every iteration (i.e. file)
1419+
* otherwise only the first iteration will have updates attributes
1420+
*/
1421+
setDirty(allDirty);
14181422
// Phase 1
14191423
switch (openIterationIfDirty(it->first, it->second))
14201424
{
@@ -1461,12 +1465,7 @@ void Series::flushFileBased(
14611465
it->second.get().m_closed =
14621466
internal::CloseStatus::ClosedInBackend;
14631467
}
1464-
/* reset the dirty bit for every iteration (i.e. file)
1465-
* otherwise only the first iteration will have updates attributes
1466-
*/
1467-
setDirty(allDirty);
14681468
}
1469-
setDirty(false);
14701469

14711470
// Phase 3
14721471
if (flushIOHandler)

src/backend/Attributable.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121
#include "openPMD/backend/Attributable.hpp"
22+
#include "openPMD/IO/AbstractIOHandler.hpp"
2223
#include "openPMD/Iteration.hpp"
2324
#include "openPMD/ParticleSpecies.hpp"
2425
#include "openPMD/RecordComponent.hpp"
@@ -278,10 +279,10 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
278279
}
279280
}
280281
// Do this outside the if branch to also setDirty to dirtyRecursive
281-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
282-
{
283-
setDirty(false);
284-
}
282+
assert(
283+
flushParams.flushLevel != FlushLevel::SkeletonOnly &&
284+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles);
285+
setDirty(false);
285286
}
286287

287288
void Attributable::readAttributes(ReadMode mode)

0 commit comments

Comments
 (0)