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-06-29 16:22:00 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-06-29 16:22:00 (GMT)
commit25607ba5a96ff93a7d10fb426e2e0d7b2a1227bc (patch)
tree66cb9d9ce0686c23a244d4171fe3bef913a3888a
parent2d6bbb593b3e19225e37640459ce319d726eaaa4 (diff)
Remake the cache when the DS returns an unexpected amount of entriessucrose-0.84
-rw-r--r--src/jarabe/journal/model.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index b6d2bde..19d437b 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -153,7 +153,13 @@ class BaseResultSet(object):
query = self._query.copy()
query['limit'] = self._cache_limit
query['offset'] = offset
- entries, self._total_count = self.find(query)
+ entries, total_count = self.find(query)
+
+ if total_count != self._total_count:
+ logging.warning('Inconsistency detected, remaking the cache')
+ self._offset = 0
+ self._cache.remove_all(self._cache)
+ return self.read(max_count)
self._cache.remove_all(self._cache)
self._cache.append_all(entries)
@@ -168,7 +174,13 @@ class BaseResultSet(object):
query = self._query.copy()
query['limit'] = max_count
query['offset'] = last_cached_entry
- entries, self._total_count = self.find(query)
+ entries, total_count = self.find(query)
+
+ if total_count != self._total_count:
+ logging.warning('Inconsistency detected, remaking the cache')
+ self._offset = 0
+ self._cache.remove_all(self._cache)
+ return self.read(max_count)
# update cache
self._cache.append_all(entries)
@@ -190,7 +202,13 @@ class BaseResultSet(object):
query = self._query.copy()
query['limit'] = limit
query['offset'] = self._offset
- entries, self._total_count = self.find(query)
+ entries, total_count = self.find(query)
+
+ if total_count != self._total_count:
+ logging.warning('Inconsistency detected, remaking the cache')
+ self._offset = 0
+ self._cache.remove_all(self._cache)
+ return self.read(max_count)
# update cache
self._cache.prepend_all(entries)