Bläddra i källkod

Don't delete an index if the sizes don't match

Daoud Clarke 2 år sedan
förälder
incheckning
c69108cfcc
2 ändrade filer med 3 tillägg och 8 borttagningar
  1. 1 1
      mwmbl/indexer/historical.py
  2. 2 7
      mwmbl/main.py

+ 1 - 1
mwmbl/indexer/historical.py

@@ -4,7 +4,7 @@ from mwmbl.crawler.app import get_batches_for_date
 from mwmbl.database import Database
 from mwmbl.indexer.indexdb import BatchInfo, BatchStatus, IndexDatabase
 
-DAYS = 20
+DAYS = 66
 
 
 def run():

+ 2 - 7
mwmbl/main.py

@@ -40,14 +40,9 @@ def run():
     try:
         existing_index = TinyIndex(item_factory=Document, index_path=index_path)
         if existing_index.page_size != PAGE_SIZE or existing_index.num_pages != args.num_pages:
-            print(f"Existing index page sizes ({existing_index.page_size}) and number of pages "
-                  f"({existing_index.num_pages}) does not match - removing.")
-            os.remove(index_path)
-            existing_index = None
+            raise ValueError(f"Existing index page sizes ({existing_index.page_size}) or number of pages "
+                             f"({existing_index.num_pages}) do not match")
     except FileNotFoundError:
-        existing_index = None
-
-    if existing_index is None:
         print("Creating a new index")
         TinyIndex.create(item_factory=Document, index_path=index_path, num_pages=args.num_pages, page_size=PAGE_SIZE)