]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
importer: Drop any data from feeds we no longer support
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Mar 2024 11:35:37 +0000 (11:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 2 Mar 2024 11:35:37 +0000 (11:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index a458fceb7b5e89f5c0bdd3ce0a7227c5f7bebb0c..355c061a0831de9bcf2ea4ac54bacc64cd1b931c 100644 (file)
@@ -1827,6 +1827,14 @@ class CLI(object):
                        ("SPAMHAUS-ASNDROP", self._import_spamhaus_asndrop, "https://www.spamhaus.org/drop/asndrop.json"),
                )
 
+               # Drop any data from feeds that we don't support (any more)
+               with self.db.transaction():
+                       # Fetch the names of all feeds we support
+                       sources = [name for name, *rest in feeds]
+
+                       self.db.execute("DELETE FROM autnum_feeds  WHERE NOT source = ANY(%s)", sources)
+                       self.db.execute("DELETE FROM network_feeds WHERE NOT source = ANY(%s)", sources)
+
                # Walk through all feeds
                for name, callback, url, *args in feeds:
                        # Skip any feeds that were not requested on the command line