]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
geofeeds: Delete any data on 404
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Jul 2023 09:53:41 +0000 (09:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Jul 2023 09:53:41 +0000 (09:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 69b48cb47081ec501beda980b7fd86041c4de136..310e4eea125d76ee77a2d8bc4c3d9b12a6b52db5 100644 (file)
@@ -1404,6 +1404,11 @@ class CLI(object):
                                self.db.execute("UPDATE geofeeds SET status = %s, error = %s \
                                        WHERE id = %s", e.code, "%s" % e, geofeed.id)
 
+                               # Remove any previous data when the feed has been deleted
+                               if e.code == 404:
+                                       self.db.execute("DELETE FROM geofeed_networks \
+                                               WHERE geofeed_id = %s", geofeed.id)
+
                        # Catch any other errors and connection timeouts
                        except (urllib.request.URLError, TimeoutError) as e:
                                log.debug("Could not fetch URL %s: %s" % (geofeed.url, e))