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 17:17:53 (GMT)
commit902883ab7c17c4bc4f31ad492902dae6ef01e1ce (patch)
tree105c870c228ae5749ce4c7d81f3664bf416f2c67
parent67b6d3154c250cf1810bc90b4d6932513cdd87c7 (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 5025cf7..7b33400 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* #3180: Recreate the index on mount failure of only removable devices. (tomeu)
+
Snapshot 23f5b3439e
Snapshot dce9c18d56
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index 293e5e9..1e82cbc 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
@@ -599,7 +601,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)