From 021941bf6f2c5137c94c54b4ee990693894f3fff Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 14 Nov 2019 18:21:08 +0100 Subject: [PATCH] Adjust last change to conftree: treat non-existing topmost file as an empty one to support lean config dirs --- src/VERSION | 2 +- src/utils/conftree.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/VERSION b/src/VERSION index dd43a143..ba60039e 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -1.26.1 +1.26.2pre1 diff --git a/src/utils/conftree.h b/src/utils/conftree.h index 7a49434c..b91a8743 100644 --- a/src/utils/conftree.h +++ b/src/utils/conftree.h @@ -62,6 +62,7 @@ #include #include #endif +#include #include "pathut.h" @@ -571,17 +572,23 @@ private: /// if some files were not readable/parsable. Now fail if any /// fails. void construct(const std::vector& fns, bool ro) { - bool ok = true; + bool ok{true}; + bool first{true}; for (const auto& fn : fns) { T* p = new T(fn.c_str(), ro); if (p && p->ok()) { m_confs.push_back(p); } else { delete p; - ok = false; + // In ro mode, we accept a non-existing topmost file + // and treat it as an empty one. + if (!(ro && first && !path_exists(fn))) { + ok = false; + } } // Only the first file is opened rw ro = true; + first = false; } m_ok = ok; }