comparison pylons_app/lib/indexers/daemon.py @ 441:c59c4d4323e7

added support for broken symlinks in whoosh indexer
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 01 Sep 2010 12:13:03 +0200
parents 28f19fa562df
children e5157e2a530e
comparison
equal deleted inserted replaced
440:9fe5ca6d72f6 441:c59c4d4323e7
84 u_content = unicode(str(content).encode('string_escape')) 84 u_content = unicode(str(content).encode('string_escape'))
85 else: 85 else:
86 log.debug(' >> %s' % path) 86 log.debug(' >> %s' % path)
87 #just index file name without it's content 87 #just index file name without it's content
88 u_content = u'' 88 u_content = u''
89 89
90 writer.add_document(owner=unicode(repo.contact), 90
91
92 try:
93 os.stat(path)
94 writer.add_document(owner=unicode(repo.contact),
91 repository=u"%s" % repo.name, 95 repository=u"%s" % repo.name,
92 path=u"%s" % path, 96 path=u"%s" % path,
93 content=u_content, 97 content=u_content,
94 modtime=os.path.getmtime(path), 98 modtime=os.path.getmtime(path),
95 extension=ext) 99 extension=ext)
100 except OSError, e:
101 import errno
102 if e.errno == errno.ENOENT:
103 log.debug('path %s does not exist or is a broken symlink' % path)
104 else:
105 raise e
106
96 107
97 def build_index(self): 108 def build_index(self):
98 if os.path.exists(IDX_LOCATION): 109 if os.path.exists(IDX_LOCATION):
99 log.debug('removing previos index') 110 log.debug('removing previos index')
100 rmtree(IDX_LOCATION) 111 rmtree(IDX_LOCATION)