changeset 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 9fe5ca6d72f6
children d66a7fa7689b
files pylons_app/lib/indexers/daemon.py
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/lib/indexers/daemon.py	Mon Aug 30 17:51:36 2010 +0200
+++ b/pylons_app/lib/indexers/daemon.py	Wed Sep 01 12:13:03 2010 +0200
@@ -86,13 +86,24 @@
             log.debug('    >> %s' % path)
             #just index file name without it's content
             u_content = u''
-                
-        writer.add_document(owner=unicode(repo.contact),
+        
+        
+        
+        try:
+            os.stat(path)
+            writer.add_document(owner=unicode(repo.contact),
                             repository=u"%s" % repo.name,
                             path=u"%s" % path,
                             content=u_content,
                             modtime=os.path.getmtime(path),
-                            extension=ext) 
+                            extension=ext)             
+        except OSError, e:
+            import errno
+            if e.errno == errno.ENOENT:
+                log.debug('path %s does not exist or is a broken symlink' % path)
+            else:
+                raise e                 
+
     
     def build_index(self):
         if os.path.exists(IDX_LOCATION):