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-12-19 18:10:57 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-12-19 18:10:57 (GMT)
commitd9bf5f08e7390c31a2d813e84c52a440f0f2076c (patch)
tree29d0f3c78f25c39d9bd07c92909c2f8e3dea5e4d
parentc263e68728d166d5e4cd7d5c84fb05d4fbd7e597 (diff)
#2545 Clean up correctly when unmounting a non-present removable device.
-rw-r--r--src/olpc/datastore/backingstore.py16
-rw-r--r--src/olpc/datastore/datastore.py7
-rw-r--r--src/olpc/datastore/xapianindex.py21
3 files changed, 32 insertions, 12 deletions
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index 12dc582..e900649 100644
--- a/src/olpc/datastore/backingstore.py
+++ b/src/olpc/datastore/backingstore.py
@@ -22,6 +22,8 @@ import threading
import errno
import shutil
import urllib
+import traceback
+import sys
import dbus
import xapian
@@ -267,11 +269,15 @@ class FileBackingStore(BackingStore):
if 'uri' not in desc: desc['uri'] = self.uri
if 'title' not in desc: desc['title'] = self.uri
-
- fp = open(fn, 'w')
- pickle.dump(desc, fp)
- fp.close()
-
+ # TODO: Would be better to check if the device is present and
+ # don't try to update the descriptor file if it's not.
+ try:
+ fp = open(fn, 'w')
+ pickle.dump(desc, fp)
+ fp.close()
+ except IOError, e:
+ logging.error('Unable to write descriptor:\n' + \
+ ''.join(traceback.format_exception(*sys.exc_info())))
@staticmethod
def parse(uri):
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index bf3cfaf..67ddca9 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -106,13 +106,10 @@ class DataStore(dbus.service.Object):
"""Unmount a mountpoint by id"""
if mountpoint_id not in self.mountpoints: return
mp = self.mountpoints[mountpoint_id]
- try:
- mp.stop()
- except:
- logger.warn("Issue with unmounting store. Trying to continue")
+ mp.stop()
- self.Unmounted(mp.descriptor())
del self.mountpoints[mountpoint_id]
+ self.Unmounted(mp.descriptor())
@dbus.service.signal(DS_DBUS_INTERFACE, signature="a{sv}")
def Mounted(self, descriptior):
diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
index d071eba..888bd26 100644
--- a/src/olpc/datastore/xapianindex.py
+++ b/src/olpc/datastore/xapianindex.py
@@ -22,6 +22,7 @@ import time
import thread
import threading
import warnings
+import traceback
import secore
import xapian as _xapian # we need to modify the QueryParser
@@ -124,7 +125,15 @@ class IndexManager(object):
logging.debug('IndexManager.stop()')
self.flush(force=True)
self.stopIndexer(force)
- self.write_index.close()
+
+ # TODO: Would be better to check if the device is present and
+ # don't try to close if it's not.
+ try:
+ self.write_index.close()
+ except _xapian.DatabaseError, e:
+ logging.debug('Index close failed:\n' + \
+ ''.join(traceback.format_exception(*sys.exc_info())))
+
#self.read_index.close()
# XXX: work around for xapian not having close() this will
# change in the future in the meantime we delete the
@@ -165,7 +174,15 @@ class IndexManager(object):
self.deltact += 1
if force or self.deltact > FLUSH_THRESHOLD:
with self._write_lock:
- self.write_index.flush()
+
+ # TODO: Would be better to check if the device is present and
+ # don't try to flush if it's not.
+ try:
+ self.write_index.flush()
+ except _xapian.DatabaseError, e:
+ logging.debug('Index flush failed:\n' + \
+ ''.join(traceback.format_exception(*sys.exc_info())))
+
#self.read_index.reopen()
self.deltact = 0
else: