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-08-13 09:06:36 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-08-13 09:06:36 (GMT)
commit065387ede564ea9b2bdb6d1a63e43e8e636eaad3 (patch)
tree8e91bb6fca9652ae6cbf20a58ea9d87c60bda1d0
parent457507b6f3ef5d8930edae3e57d935b412161437 (diff)
Don't try to rebuild the index when the layout has just been created.
-rw-r--r--src/carquinyol/datastore.py4
-rw-r--r--src/carquinyol/layoutmanager.py19
2 files changed, 18 insertions, 5 deletions
diff --git a/src/carquinyol/datastore.py b/src/carquinyol/datastore.py
index 0307046..2cda1e9 100644
--- a/src/carquinyol/datastore.py
+++ b/src/carquinyol/datastore.py
@@ -59,10 +59,10 @@ class DataStore(dbus.service.Object):
layout_manager = layoutmanager.get_instance()
if layout_manager.get_version() == 0:
migration.migrate_from_0()
- layout_manager.set_version(2)
+ layout_manager.set_version(layout_manager.CURRENT_LAYOUT_VERSION)
layout_manager.index_updated = False
elif layout_manager.get_version() == 1:
- layout_manager.set_version(2)
+ layout_manager.set_version(layout_manager.CURRENT_LAYOUT_VERSION)
layout_manager.index_updated = False
self._metadata_store = MetadataStore()
diff --git a/src/carquinyol/layoutmanager.py b/src/carquinyol/layoutmanager.py
index a017029..42db46f 100644
--- a/src/carquinyol/layoutmanager.py
+++ b/src/carquinyol/layoutmanager.py
@@ -17,7 +17,7 @@
import os
MAX_QUERY_LIMIT = 40960
-
+CURRENT_LAYOUT_VERSION = 2
class LayoutManager(object):
"""Provide the logic about how entries are stored inside the datastore
@@ -32,13 +32,19 @@ class LayoutManager(object):
if not os.path.exists(self._root_path):
os.makedirs(self._root_path)
- self.set_version(1)
self._create_if_needed(self.get_checksums_dir())
self._create_if_needed(self.get_queue_path())
index_updated_path = os.path.join(self._root_path, 'index_updated')
- self._index_updated = os.path.exists(index_updated_path)
+ if os.path.exists(index_updated_path):
+ self._index_updated = True
+ elif self._is_empty():
+ open(index_updated_path, 'w').close()
+ self.set_version(CURRENT_LAYOUT_VERSION)
+ self._index_updated = True
+ else:
+ self._index_updated = False
def _create_if_needed(self, path):
if not os.path.exists(path):
@@ -95,6 +101,13 @@ class LayoutManager(object):
uids.append(g)
return uids
+ def _is_empty(self):
+ for f in os.listdir(self._root_path):
+ if os.path.isdir(os.path.join(self._root_path, f)) and len(f) == 2:
+ for g in os.listdir(os.path.join(self._root_path, f)):
+ if len(g) == 36:
+ return False
+ return True
_instance = None
def get_instance():