changeset 465:e01a85f9fc90

fixed initial whoosh indexer. Build full index on first run even with incremental flag
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 08 Sep 2010 01:33:38 +0200
parents cbe777be5b8c
children 183cee110578
files pylons_app/lib/indexers/daemon.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/lib/indexers/daemon.py	Tue Sep 07 01:39:12 2010 +0200
+++ b/pylons_app/lib/indexers/daemon.py	Wed Sep 08 01:33:38 2010 +0200
@@ -56,6 +56,12 @@
     def __init__(self, indexname='HG_INDEX', repo_location=None):
         self.indexname = indexname
         self.repo_location = repo_location
+        self.initial = False
+        if not os.path.isdir(IDX_LOCATION):
+            os.mkdir(IDX_LOCATION)
+            log.info('Cannot run incremental index since it does not'
+                     ' yet exist running full build')
+            self.initial = True
     
     def get_paths(self, root_dir):
         """recursive walk in root dir and return a set of all path in that dir
@@ -178,7 +184,7 @@
         
     def run(self, full_index=False):
         """Run daemon"""
-        if full_index:
+        if full_index or self.initial:
             self.build_index()
         else:
             self.update_index()