Skip to content

Commit 6da1081

Browse files
committed
Fixes to the dirty/dirtyRecursive logic
1 parent 8dc3173 commit 6da1081

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
@@ -360,12 +360,13 @@ void Iteration::flushIteration(internal::FlushParams const &flushParams)
360360
s.setParticlesPath(particlesPaths);
361361
}
362362

363-
if (access::write(IOHandler()->m_frontendAccess))
364-
{
365-
flushAttributes(flushParams);
366-
}
367-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
363+
if (flushParams.flushLevel != FlushLevel::SkeletonOnly &&
364+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles)
368365
{
366+
if (access::write(IOHandler()->m_frontendAccess))
367+
{
368+
flushAttributes(flushParams);
369+
}
369370
setDirty(false);
370371
meshes.setDirty(false);
371372
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"
@@ -283,10 +284,10 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
283284
}
284285
}
285286
// Do this outside the if branch to also setDirty to dirtyRecursive
286-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
287-
{
288-
setDirty(false);
289-
}
287+
assert(
288+
flushParams.flushLevel != FlushLevel::SkeletonOnly &&
289+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles);
290+
setDirty(false);
290291
}
291292

292293
void Attributable::readAttributes(ReadMode mode)

0 commit comments

Comments
 (0)