Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2010-09-03 05:12:12 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-09-03 05:12:12 (GMT)
commit9bd6a51f9f14184f014de4cb6f851d4e373202f9 (patch)
tree5bbd2933ff03d1ac40fb52811d7796ce11a9734a
parent62d136ed8a49fa0f9de5c578616d92041aff446c (diff)
commit 3644fac reintroduced race condition, broke test suite #2104
-rw-r--r--src/carquinyol/datastore.py26
-rw-r--r--src/carquinyol/layoutmanager.py2
2 files changed, 19 insertions, 9 deletions
diff --git a/src/carquinyol/datastore.py b/src/carquinyol/datastore.py
index 46cf5fd..839a396 100644
--- a/src/carquinyol/datastore.py
+++ b/src/carquinyol/datastore.py
@@ -56,7 +56,7 @@ class DataStore(dbus.service.Object):
allow_replacement=False)
dbus.service.Object.__init__(self, bus_name, DS_OBJECT_PATH)
- migrated = self._migrate()
+ migrated, initiated = self._open_layout()
self._metadata_store = MetadataStore()
self._file_store = FileStore()
@@ -75,26 +75,36 @@ class DataStore(dbus.service.Object):
self._rebuild_index()
return
- if not self._index_store.index_updated:
+ if initiated:
+ logging.debug('Initiate datastore')
+ self._index_store.flush()
+ elif not self._index_store.index_updated:
logging.debug('Index is not up-to-date, will update')
self._update_index()
- def _migrate(self):
- """Check version of data store on disk and migrate if necessary.
+ def _open_layout(self):
+ """Open layout manager, check version of data store on disk and
+ migrate if necessary.
- Returns True if migration was done and an index rebuild is required,
- False otherwise.
+ Returns a pair of booleans. For the first, True if migration was done
+ and an index rebuild is required. For the second, True if datastore was
+ just initiated.
"""
layout_manager = layoutmanager.get_instance()
+
+ if layout_manager.is_empty():
+ layout_manager.set_version(layoutmanager.CURRENT_LAYOUT_VERSION)
+ return False, True
+
old_version = layout_manager.get_version()
if old_version == layoutmanager.CURRENT_LAYOUT_VERSION:
- return False
+ return False, False
if old_version == 0:
migration.migrate_from_0()
layout_manager.set_version(layoutmanager.CURRENT_LAYOUT_VERSION)
- return True
+ return True, False
def _rebuild_index(self):
"""Remove and recreate index."""
diff --git a/src/carquinyol/layoutmanager.py b/src/carquinyol/layoutmanager.py
index 983f64c..335614f 100644
--- a/src/carquinyol/layoutmanager.py
+++ b/src/carquinyol/layoutmanager.py
@@ -88,7 +88,7 @@ class LayoutManager(object):
uids.append(g)
return uids
- def _is_empty(self):
+ def is_empty(self):
"""Check if there is any existing entry.
All data store layout versions are handled. Will err on the safe