From: Michael Tremer Date: Sat, 6 Dec 2025 19:09:16 +0000 (+0000) Subject: dnsbl: Make the list only as updated when we actually have new data X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f0a86857e120b3afa8d4d4e7a72892c9dc91373;p=dbl.git dnsbl: Make the list only as updated when we actually have new data Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/lists.py b/src/dnsbl/lists.py index 2037f96..679cdaa 100644 --- a/src/dnsbl/lists.py +++ b/src/dnsbl/lists.py @@ -197,12 +197,16 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): Updates the list """ with self.backend.db.transaction(): - # Update the timestamp - self.updated_at = sqlmodel.func.current_timestamp() + updated = False # Update all sources for source in self.sources: - source.update() + if source.update(): + updated = True + + # Update the timestamp if at least one source has actually fetched new data + if updated: + self.updated_at = sqlmodel.func.current_timestamp() # Export! diff --git a/src/dnsbl/sources.py b/src/dnsbl/sources.py index 1def5d7..dcad9d7 100644 --- a/src/dnsbl/sources.py +++ b/src/dnsbl/sources.py @@ -126,7 +126,7 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): # There is nothing to do if the source has not changed if response.status_code == 304: log.debug("Source %s has not been changed, skipping processing" % self) - return + return False # Add all domains for line in response.iter_lines(): @@ -139,6 +139,9 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): # Mark all domains that have not been updated as removed self.__prune() + # Signal that we have actually fetched new data + return True + def _make_headers(self): """ Creates some headers we will send with the request.