Public feed #725679

Miscellany

public text v1 · immutable
Raw Edit
·published 2007-10-04 17:01 UTC
rendered paste body
diff --git a/NEWS b/NEWS
index d4b7143..ef3bdcf 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* #3180: Recreate the index on mount failure of only removable devices. (tomeu)
+
 Snapshot dce9c18d56
 
 * #3469 Human readable names on USB. (marco)
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index b1ecbef..8d5909c 100644
--- a/src/olpc/datastore/backingstore.py
+++ b/src/olpc/datastore/backingstore.py
@@ -20,6 +20,8 @@ import subprocess
 import time
 import threading
 
+import xapian
+
 from olpc.datastore.xapianindex import IndexManager
 from olpc.datastore import bin_copy
 from olpc.datastore import utils
@@ -598,7 +600,25 @@ class InplaceFileBackingStore(FileBackingStore):
 
         
     def load(self):
-        super(InplaceFileBackingStore, self).load()
+        try:
+            super(InplaceFileBackingStore, self).load()
+        except xapian.DatabaseCorruptError, e:
+            # TODO: Try to recover in a smarter way than deleting the base
+            # dir and reinitializing the index.
+
+            logging.error('Error while trying to load mount point %s: %s. ' \
+                            'Will try to renitialize and load again.' % (self.base, e))
+
+            # Delete the base dir and its contents
+            for root, dirs, files in os.walk(self.base, topdown=False):
+                for name in files:
+                    os.remove(os.path.join(root, name))
+                os.rmdir(root)
+
+            self.initialize()
+            self.load()
+            return
+
         # now map/update the existing data into the indexes
         # but do it async
         self.walker = threading.Thread(target=self._walk)