comparison pylons_app/lib/indexers/daemon.py @ 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 f19d3ee89335
children a9e50dce3081
comparison
equal deleted inserted replaced
464:cbe777be5b8c 465:e01a85f9fc90
54 """Deamon for atomic jobs""" 54 """Deamon for atomic jobs"""
55 55
56 def __init__(self, indexname='HG_INDEX', repo_location=None): 56 def __init__(self, indexname='HG_INDEX', repo_location=None):
57 self.indexname = indexname 57 self.indexname = indexname
58 self.repo_location = repo_location 58 self.repo_location = repo_location
59 self.initial = False
60 if not os.path.isdir(IDX_LOCATION):
61 os.mkdir(IDX_LOCATION)
62 log.info('Cannot run incremental index since it does not'
63 ' yet exist running full build')
64 self.initial = True
59 65
60 def get_paths(self, root_dir): 66 def get_paths(self, root_dir):
61 """recursive walk in root dir and return a set of all path in that dir 67 """recursive walk in root dir and return a set of all path in that dir
62 excluding files in .hg dir""" 68 excluding files in .hg dir"""
63 index_paths_ = set() 69 index_paths_ = set()
176 #idx.optimize() 182 #idx.optimize()
177 log.debug('>>> FINISHED <<<') 183 log.debug('>>> FINISHED <<<')
178 184
179 def run(self, full_index=False): 185 def run(self, full_index=False):
180 """Run daemon""" 186 """Run daemon"""
181 if full_index: 187 if full_index or self.initial:
182 self.build_index() 188 self.build_index()
183 else: 189 else:
184 self.update_index() 190 self.update_index()
185 191
186 if __name__ == "__main__": 192 if __name__ == "__main__":