Skip to content

Commit fbb686a

Browse files
committed
Fixes to the dirty/dirtyRecursive logic
1 parent 49082d6 commit fbb686a

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
@@ -363,12 +363,13 @@ void Iteration::flushIteration(internal::FlushParams const &flushParams)
363363
s.setParticlesPath(particlesPaths);
364364
}
365365

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

src/Series.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,13 @@ void Series::flushFileBased(
14061406
case Access::READ_WRITE:
14071407
case Access::CREATE:
14081408
case Access::APPEND: {
1409-
bool allDirty = dirty();
1409+
bool const allDirty = dirty();
14101410
for (auto it = begin; it != end; ++it)
14111411
{
1412+
/* reset the dirty bit for every iteration (i.e. file)
1413+
* otherwise only the first iteration will have updates attributes
1414+
*/
1415+
setDirty(allDirty);
14121416
// Phase 1
14131417
switch (openIterationIfDirty(it->first, it->second))
14141418
{
@@ -1459,12 +1463,7 @@ void Series::flushFileBased(
14591463
{
14601464
IOHandler()->flush(flushParams);
14611465
}
1462-
/* reset the dirty bit for every iteration (i.e. file)
1463-
* otherwise only the first iteration will have updates attributes
1464-
*/
1465-
setDirty(allDirty);
14661466
}
1467-
setDirty(false);
14681467
break;
14691468
}
14701469
}

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/Series.hpp"
2425
#include "openPMD/auxiliary/DerefDynamicCast.hpp"
@@ -275,10 +276,10 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
275276
}
276277
}
277278
// Do this outside the if branch to also setDirty to dirtyRecursive
278-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
279-
{
280-
setDirty(false);
281-
}
279+
assert(
280+
flushParams.flushLevel != FlushLevel::SkeletonOnly &&
281+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles);
282+
setDirty(false);
282283
}
283284

284285
void Attributable::readAttributes(ReadMode mode)

0 commit comments

Comments
 (0)