Skip to content

Commit 5376ba6

Browse files
committed
Fixes to the dirty/dirtyRecursive logic
1 parent b74748b commit 5376ba6

4 files changed

Lines changed: 21 additions & 16 deletions

File tree

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
@@ -1418,9 +1418,13 @@ void Series::flushFileBased(
14181418
case Access::READ_WRITE:
14191419
case Access::CREATE:
14201420
case Access::APPEND: {
1421-
bool allDirty = dirty();
1421+
bool const allDirty = dirty();
14221422
for (auto it = begin; it != end; ++it)
14231423
{
1424+
/* reset the dirty bit for every iteration (i.e. file)
1425+
* otherwise only the first iteration will have updates attributes
1426+
*/
1427+
setDirty(allDirty);
14241428
// Phase 1
14251429
switch (openIterationIfDirty(it->first, it->second))
14261430
{
@@ -1467,12 +1471,7 @@ void Series::flushFileBased(
14671471
it->second.get().m_closed =
14681472
internal::CloseStatus::ClosedInBackend;
14691473
}
1470-
/* reset the dirty bit for every iteration (i.e. file)
1471-
* otherwise only the first iteration will have updates attributes
1472-
*/
1473-
setDirty(allDirty);
14741474
}
1475-
setDirty(false);
14761475

14771476
// Phase 3
14781477
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"
@@ -293,10 +294,10 @@ void Attributable::flushAttributes(internal::FlushParams const &flushParams)
293294
}
294295
}
295296
// Do this outside the if branch to also setDirty to dirtyRecursive
296-
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
297-
{
298-
setDirty(false);
299-
}
297+
assert(
298+
flushParams.flushLevel != FlushLevel::SkeletonOnly &&
299+
flushParams.flushLevel != FlushLevel::CreateOrOpenFiles);
300+
setDirty(false);
300301
}
301302

302303
void Attributable::readAttributes(ReadMode mode)

0 commit comments

Comments
 (0)