]> git.ipfire.org Git - dbl.git/commitdiff
dnsbl: Make the list only as updated when we actually have new data
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 19:09:16 +0000 (19:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Dec 2025 19:09:16 +0000 (19:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/lists.py
src/dnsbl/sources.py

index 2037f960ac84c4151513fca9dcf84fddbe9fe2c1..679cdaa17a64eec2cd1db8c5a597b87956eff162 100644 (file)
@@ -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!
 
index 1def5d76e238d6b04c4109e8f7db37e2a5869e39..dcad9d73b5c49fff96b6aa4143cac3659ecd838e 100644 (file)
@@ -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.