Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-07 15:31:05 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-07 15:31:05 (GMT)
commitf67d9ff83e448097d9328b1100df8f8ea4575353 (patch)
tree467da385efdab282492aa046e4d807b28d6e215e
parent551e3282fda082ef610c53a69867ef103114c513 (diff)
Fallback to file system if we fail to query the index
-rw-r--r--src/olpc/datastore/datastore.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index 76b771c..03b5930 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -191,16 +191,7 @@ class DataStore(dbus.service.Object):
logging.debug('datastore.find %r' % query)
t = time.time()
- if not layoutmanager.get_instance().index_updated:
- logging.warning('Index updating, returning all entries')
-
- uids = layoutmanager.get_instance().find_all()
- count = len(uids)
-
- offset = query.get('offset', 0)
- limit = query.get('limit', MAX_QUERY_LIMIT)
- uids = uids[offset:offset + limit]
- else:
+ if layoutmanager.get_instance().index_updated:
try:
uids, count = self._index_store.find(query)
except Exception:
@@ -212,6 +203,16 @@ class DataStore(dbus.service.Object):
self._index_store.open_index()
self._rebuild_index()
+ if not layoutmanager.get_instance().index_updated:
+ logging.warning('Index updating, returning all entries')
+
+ uids = layoutmanager.get_instance().find_all()
+ count = len(uids)
+
+ offset = query.get('offset', 0)
+ limit = query.get('limit', MAX_QUERY_LIMIT)
+ uids = uids[offset:offset + limit]
+
entries = []
for uid in uids:
metadata = self._metadata_store.retrieve(uid, properties)