From 57b2d5c47a65b940229d87cc91cfca676481541a Mon Sep 17 00:00:00 2001 From: Josh Humphries Date: Mon, 16 May 2022 11:50:15 +0100 Subject: [PATCH 1/3] Calculate percentage for status correctly... --- iiif/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiif/utils.py b/iiif/utils.py index bb54f37..e197292 100644 --- a/iiif/utils.py +++ b/iiif/utils.py @@ -290,7 +290,7 @@ def pct(self) -> str: :return: the percentage the cache is in use as a formatted string """ - return f'{(self.total_size / self.max_size):.2f}%' + return f'{((self.total_size / self.max_size) * 100):.2f}%' def _clean_up(self, path: Path): """ From 22d8d0196e3cb4ba3b9f382fc55ce97c871ea8eb Mon Sep 17 00:00:00 2001 From: Josh Humphries Date: Mon, 16 May 2022 12:04:51 +0100 Subject: [PATCH 2/3] Actually count the errors that occur on fetch --- iiif/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/iiif/utils.py b/iiif/utils.py index e197292..f74e061 100644 --- a/iiif/utils.py +++ b/iiif/utils.py @@ -361,7 +361,11 @@ async def use(self, fetchable: Fetchable) -> Path: elif not path.exists(): async with self._locker.acquire(path, timeout=self.fetch_timeout): if not path.exists(): - await self._fetch(fetchable) + try: + await self._fetch(fetchable) + except Exception: + self.errors += 1 + raise self._sizes[path] = path.stat().st_size self.total_size += self._sizes[path] From a4392e5b3f8c24a08d3201e10d8d1f0882927797 Mon Sep 17 00:00:00 2001 From: Josh Humphries Date: Mon, 16 May 2022 13:23:24 +0100 Subject: [PATCH 3/3] Update version to v0.12.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 38890de..d15e192 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ setup( name="iiif-image-server", - version='0.10.0', + version='0.12.1', author='Natural History Museum', author_email='data@nhm.ac.uk', description="A media server primarily used by the NHM Data Portal",