Skip to content

Commit e802805

Browse files
committed
Dont fail on missing Counter metadata
1 parent cf6b1d8 commit e802805

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 1.4.3
22

3-
* n/a
3+
* `zim.Archive.counters` wont fail on missing `Counter` metadata
44

55
# 1.4.2
66

src/zimscraperlib/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.3.dev0
1+
1.4.3

src/zimscraperlib/zim/_libkiwix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def parseMimetypeCounter(
7979
mtc = parseASingleMimetypeCounter(mtcStr)
8080
if mtc.mimetype:
8181
counters.update([mtc])
82+
ss.close()
8283
return counters
8384

8485

src/zimscraperlib/zim/archive.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def get_search_results_count(self, query: str) -> int:
8686

8787
@property
8888
def counters(self) -> Dict[str, int]:
89-
return parseMimetypeCounter(self.get_text_metadata("Counter"))
89+
try:
90+
return parseMimetypeCounter(self.get_text_metadata("Counter"))
91+
except RuntimeError:
92+
return {}
9093

9194
@property
9295
def article_counter(self) -> int:

0 commit comments

Comments
 (0)