Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-10-04 17:06:15 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-10-04 18:34:09 (GMT)
commit0697728b068cec6b16c7eb909b0a5213c4a2aa19 (patch)
tree558e88004e4ba20e7b9e9b2f2e027b84b90f7b63
parent419929087705c924f2ddf9cb7e70946d28456d08 (diff)
#3180: Recreate the index on mount failure of only removable devices.
-rw-r--r--NEWS2
-rw-r--r--src/olpc/datastore/backingstore.py22
2 files changed, 23 insertions, 1 deletions
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)