Skip to content

Commit 5815e91

Browse files
committed
fixup! Ensure cluster cache is properly clean in case of exception in constructor.
1 parent 951d2da commit 5815e91

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/fileimpl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ class Grouping
248248
const_cast<entry_index_t&>(m_endUserEntry) = getCountArticles();
249249
}
250250

251-
// Following code will may create cluster and
251+
// Following code will may create cluster and we want to remove them from cache
252+
// if something goes wrong.
252253
try {
253254
auto result = tmpDirentLookup.find('X', "listing/titleOrdered/v1");
254255
if (result.first) {
@@ -268,17 +269,16 @@ class Grouping
268269

269270
readMimeTypes();
270271
} catch (...) {
271-
dropCachedCluster();
272+
dropCachedClusters();
272273
throw;
273274
}
274275
}
275276

276277
FileImpl::~FileImpl() {
277-
// We have to clean the global cache for our clusters.
278-
dropCachedCluster();
278+
dropCachedClusters();
279279
}
280280

281-
void FileImpl::dropCachedCluster() const {
281+
void FileImpl::dropCachedClusters() const {
282282
getClusterCache().dropAll([=](const std::tuple<FileImpl*, cluster_index_type>& key) {return std::get<0>(key) == this;});
283283
}
284284

src/fileimpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ namespace zim
166166
explicit FileImpl(std::shared_ptr<FileCompound> zimFile);
167167
FileImpl(std::shared_ptr<FileCompound> zimFile, offset_t offset, zsize_t size);
168168

169-
void dropCachedCluster() const;
169+
void dropCachedClusters() const;
170170

171171
std::unique_ptr<IndirectDirentAccessor> getTitleAccessorV1(const entry_index_t idx);
172172
std::unique_ptr<IndirectDirentAccessor> getTitleAccessor(const offset_t offset, const zsize_t size, const std::string& name);

0 commit comments

Comments
 (0)