]> git.ipfire.org Git - location/libloc.git/commitdiff
importer: Move importing extended sources/ARIN into transaction
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Aug 2022 13:56:17 +0000 (13:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Aug 2022 13:56:17 +0000 (13:56 +0000)
All imports should have been conducted in one large transaction so that
we can remove any previous data.

This was not the case because of an indentation issue and could have
caused that the transaction was commited without all data being
successfully re-imported.

Fixes: #12852
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 01470f709888dc6a72d2e1edc67a560567a615ae..b2422754fc960e550ad4ceda8d4c890406f0cf10 100644 (file)
@@ -512,16 +512,15 @@ class CLI(object):
                                ON CONFLICT (number) DO UPDATE SET name = excluded.name;
                        """)
 
-               # Download all extended sources
-               for source_key in location.importer.EXTENDED_SOURCES:
-                       for single_url in location.importer.EXTENDED_SOURCES[source_key]:
-                               with self.db.transaction():
+                       # Download all extended sources
+                       for source_key in location.importer.EXTENDED_SOURCES:
+                               for single_url in location.importer.EXTENDED_SOURCES[source_key]:
                                        # Download data
                                        for line in downloader.request_lines(single_url):
                                                self._parse_line(line, source_key, validcountries)
 
-               # Download and import (technical) AS names from ARIN
-               self._import_as_names_from_arin()
+                       # Download and import (technical) AS names from ARIN
+                       self._import_as_names_from_arin()
 
        def _check_parsed_network(self, network):
                """