Skip to content

Commit fd7a443

Browse files
committed
Fixes to the dirty/dirtyRecursive logic
1 parent 22062d9 commit fd7a443

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
@@ -351,12 +351,13 @@ void Iteration::flushIteration(internal::FlushParams const &flushParams)
351351
s.setParticlesPath(particlesPaths);
352352
}
353353

354-
if (access::write(IOHandler()->m_frontendAccess))
355-
{
356-
flushAttributes(flushParams);
357-
}
358-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
354+
if (flushParams.flushLevel != FlushLevel::SkeletonOnly &&
355+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles)
359356
{
357+
if (access::write(IOHandler()->m_frontendAccess))
358+
{
359+
flushAttributes(flushParams);
360+
}
360361
setDirty(false);
361362
meshes.setDirty(false);
362363
particles.setDirty(false);

src/Series.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,13 @@ void Series::flushFileBased(
11341134
case Access::READ_WRITE:
11351135
case Access::CREATE:
11361136
case Access::APPEND: {
1137-
bool allDirty = dirty();
1137+
bool const allDirty = dirty();
11381138
for (auto it = begin; it != end; ++it)
11391139
{
1140+
/* reset the dirty bit for every iteration (i.e. file)
1141+
* otherwise only the first iteration will have updates attributes
1142+
*/
1143+
setDirty(allDirty);
11401144
// Phase 1
11411145
switch (openIterationIfDirty(it->first, it->second))
11421146
{
@@ -1187,12 +1191,7 @@ void Series::flushFileBased(
11871191
{
11881192
IOHandler()->flush(flushParams);
11891193
}
1190-
/* reset the dirty bit for every iteration (i.e. file)
1191-
* otherwise only the first iteration will have updates attributes
1192-
*/
1193-
setDirty(allDirty);
11941194
}
1195-
setDirty(false);
11961195
break;
11971196
}
11981197
}

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)