From bba992dc029e6cf903153cb627a03a2dc91f2f0d Mon Sep 17 00:00:00 2001 From: Markil 3 Date: Sat, 2 Aug 2025 14:13:00 -0600 Subject: [PATCH] Uses flags for all checks They get a lot less complicated, and I have to chase fewer bugs --- comic_download/comic_strip.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/comic_download/comic_strip.py b/comic_download/comic_strip.py index a79c8e6..dd7c42f 100644 --- a/comic_download/comic_strip.py +++ b/comic_download/comic_strip.py @@ -102,6 +102,8 @@ class ImageRepo(ABC): self._data_loaded = False """A flag for when the data has been successfully loaded.""" + self._data_downloaded = False + """A flag for when the data has been successfully downloaded.""" self._load_lock = Condition(Lock()) """A lock for enforcing thread safety when loading this repository.""" self._download_lock = Condition(Lock()) @@ -122,7 +124,7 @@ class ImageRepo(ABC): :returns: True if the data has been fully loaded, false otherwise. """ - return not self._load_lock._lock.locked() and self._data_loaded + return self._data_loaded def is_downloaded(self): """ @@ -130,7 +132,7 @@ class ImageRepo(ABC): :returns: True if the images have been fully downloaded, false otherwise. """ - return not self.image_urls or (not self._download_lock._lock.locked() and self.images) + return self._data_downloaded def load_data(self): """ @@ -202,6 +204,7 @@ class ImageRepo(ABC): logging.info("Downloading %s", self.get_identifier_string()) self._download_data() logging.info("Completed downloading of %s", self.get_identifier_string()) + self._data_downloaded = True self._download_lock.notify_all() def await_download(self):