]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/clicmd/refresh.py
Improved performance of the postcodes query and some code cleaning
[nominatim.git] / nominatim / clicmd / refresh.py
index 386516d6ec9297073c5a29f124784a6b7541ecad..fbc23350c7212478f8c8b0c9fa484ec154f9f070 100644 (file)
@@ -52,13 +52,17 @@ class UpdateRefresh:
 
 
         if args.postcodes:
-            LOG.warning("Update postcodes centroid")
-            tokenizer = self._get_tokenizer(args.config)
-            postcodes.update_postcodes(args.config.get_libpq_dsn(),
-                                       args.project_dir, tokenizer)
-            indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
-                              args.threads or 1)
-            indexer.index_postcodes()
+            if postcodes.can_compute(args.config.get_libpq_dsn()):
+                LOG.warning("Update postcodes centroid")
+                tokenizer = self._get_tokenizer(args.config)
+                postcodes.update_postcodes(args.config.get_libpq_dsn(),
+                                           args.project_dir, tokenizer)
+                indexer = Indexer(args.config.get_libpq_dsn(), tokenizer,
+                                  args.threads or 1)
+                indexer.index_postcodes()
+            else:
+                LOG.error("The place table doesn\'t exist. " \
+                          "Postcode updates on a frozen database is not possible.")
 
         if args.word_counts:
             LOG.warning('Recompute frequency of full-word search terms')