@@ -577,28 +577,34 @@ Given file pattern: ')END"
577577 case Access::READ_WRITE : {
578578 /* Allow creation of values in Containers and setting of Attributes
579579 * Would throw for Access::READ_ONLY */
580- auto oldType = IOHandler ()->m_frontendAccess ;
581- auto newType = const_cast <Access *>(&IOHandler ()->m_frontendAccess );
582- *newType = Access::READ_WRITE ;
580+ IOHandler ()->m_seriesStatus = internal::SeriesStatus::Parsing;
583581
584- if (input->iterationEncoding == IterationEncoding::fileBased)
585- readFileBased ();
586- else
587- readGorVBased ();
588-
589- if (series.iterations .empty ())
582+ try
590583 {
591- /* Access::READ_WRITE can be used to create a new Series
592- * allow setting attributes in that case */
593- written () = false ;
584+ if (input->iterationEncoding == IterationEncoding::fileBased)
585+ readFileBased ();
586+ else
587+ readGorVBased ();
594588
595- initDefaults (input->iterationEncoding );
596- setIterationEncoding (input->iterationEncoding );
589+ if (series.iterations .empty ())
590+ {
591+ /* Access::READ_WRITE can be used to create a new Series
592+ * allow setting attributes in that case */
593+ written () = false ;
597594
598- written () = true ;
595+ initDefaults (input->iterationEncoding );
596+ setIterationEncoding (input->iterationEncoding );
597+
598+ written () = true ;
599+ }
600+ }
601+ catch (...)
602+ {
603+ IOHandler ()->m_seriesStatus = internal::SeriesStatus::Default;
604+ throw ;
599605 }
600606
601- *newType = oldType ;
607+ IOHandler ()-> m_seriesStatus = internal::SeriesStatus::Default ;
602608 break ;
603609 }
604610 case Access::CREATE : {
@@ -784,7 +790,7 @@ void Series::flushFileBased(
784790 dirty () |= it->second .dirty ();
785791 std::string filename = iterationFilename (it->first );
786792
787- if (!it->second .written ())
793+ if (!it->second .written ())
788794 {
789795 series.m_currentlyActiveIterations .emplace (it->first );
790796 }
@@ -1207,19 +1213,18 @@ std::optional<std::deque<uint64_t> > Series::readGorVBased(bool do_init)
12071213 readAttributes (ReadMode::IgnoreExisting);
12081214
12091215 auto withRWAccess = [this ](auto &&functor) {
1210- auto oldType = IOHandler ()->m_frontendAccess ;
1211- auto newType = const_cast <Access *>(&IOHandler ()->m_frontendAccess );
1212- *newType = Access::READ_WRITE ;
1216+ auto oldStatus = IOHandler ()->m_seriesStatus ;
1217+ IOHandler ()->m_seriesStatus = internal::SeriesStatus::Parsing;
12131218 try
12141219 {
12151220 std::forward<decltype (functor)>(functor)();
12161221 }
12171222 catch (...)
12181223 {
1219- *newType = oldType ;
1224+ IOHandler ()-> m_seriesStatus = oldStatus ;
12201225 throw ;
12211226 }
1222- *newType = oldType ;
1227+ IOHandler ()-> m_seriesStatus = oldStatus ;
12231228 };
12241229
12251230 /*
@@ -1234,7 +1239,7 @@ std::optional<std::deque<uint64_t> > Series::readGorVBased(bool do_init)
12341239 IOHandler ()->enqueue (IOTask (&series.iterations , pList));
12351240 IOHandler ()->flush (internal::defaultFlushParams);
12361241
1237- auto readSingleIteration = [&series, &pOpen, this ](
1242+ auto readSingleIteration = [&series, &pOpen, this , withRWAccess ](
12381243 uint64_t index,
12391244 std::string path,
12401245 bool guardAgainstRereading,
@@ -1253,12 +1258,7 @@ std::optional<std::deque<uint64_t> > Series::readGorVBased(bool do_init)
12531258 {
12541259 pOpen.path = path;
12551260 IOHandler ()->enqueue (IOTask (&i, pOpen));
1256- auto oldType = IOHandler ()->m_frontendAccess ;
1257- auto newType =
1258- const_cast <Access *>(&IOHandler ()->m_frontendAccess );
1259- *newType = Access::READ_WRITE ;
1260- i.reread (path);
1261- *newType = oldType;
1261+ withRWAccess ([&i, &path]() { i.reread (path); });
12621262 }
12631263 }
12641264 else
@@ -1622,7 +1622,8 @@ AdvanceStatus Series::advance(
16221622void Series::flushStep (bool doFlush)
16231623{
16241624 auto &series = get ();
1625- if (!series.m_currentlyActiveIterations .empty ())
1625+ if (!series.m_currentlyActiveIterations .empty () &&
1626+ IOHandler ()->m_frontendAccess != Access::READ_ONLY )
16261627 {
16271628 /*
16281629 * Warning: changing attribute extents over time (probably) unsupported
0 commit comments