File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ class Grouping
188188 {}
189189#endif
190190
191- FileImpl::FileImpl (std::shared_ptr<FileCompound> _zimFile)
191+ FileImpl::FileImpl (std::shared_ptr<FileCompound> _zimFile) try
192192 : zimFile (_zimFile),
193193 zimReader (makeFileReader (zimFile)),
194194 direntReader (new DirentReader (zimReader)),
@@ -265,6 +265,9 @@ class Grouping
265265 m_byTitleDirentLookup.reset (new ByTitleDirentLookup (mp_titleDirentAccessor.get ()));
266266
267267 readMimeTypes ();
268+ } catch (...) {
269+ getClusterCache ().drop_all ([=](const std::tuple<FileImpl*, cluster_index_type>& key) {return std::get<0 >(key) == this ;});
270+ throw ;
268271 }
269272
270273 FileImpl::~FileImpl () {
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ class ZimArchive: public testing::Test {
5050 zim::set_cluster_cache_max_size (CLUSTER_CACHE_SIZE);
5151 ASSERT_EQ (zim::get_cluster_cache_current_size (), 0 );
5252 }
53+ void TearDown () override {
54+ ASSERT_EQ (zim::get_cluster_cache_current_size (), 0 );
55+ }
5356};
5457
5558using TestContextImpl = std::vector<std::pair<std::string, std::string> >;
@@ -669,7 +672,8 @@ class CapturedStderr
669672#define EXPECT_BROKEN_ZIMFILE (ZIMPATH, EXPECTED_STDERROR_TEXT ) \
670673 CapturedStderr stderror; \
671674 EXPECT_FALSE (zim::validate(ZIMPATH, checksToRun)); \
672- EXPECT_EQ (EXPECTED_STDERROR_TEXT, std::string(stderror)) << ZIMPATH;
675+ EXPECT_EQ (EXPECTED_STDERROR_TEXT, std::string(stderror)) << ZIMPATH; \
676+ ASSERT_EQ (zim::get_cluster_cache_current_size(), 0 );
673677
674678#define TEST_BROKEN_ZIM_NAME (ZIMNAME, EXPECTED ) \
675679for (auto & testfile: getDataFilePath(ZIMNAME)) {EXPECT_BROKEN_ZIMFILE (testfile.path , EXPECTED)}
You can’t perform that action at this time.
0 commit comments