From: Michael Tremer Date: Sat, 2 Mar 2024 11:35:37 +0000 (+0000) Subject: importer: Drop any data from feeds we no longer support X-Git-Tag: 0.9.18~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=659c2810448bad51b1644da0cf934596020f366c;p=location%2Flibloc.git importer: Drop any data from feeds we no longer support Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index a458fce..355c061 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -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