Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2010-09-13 19:02:57 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-09-13 20:41:43 (GMT)
commitcd616ec1d17f78a217a819e6164c90603a8c34c7 (patch)
treee604b2efc483526b45de3036376f4134f077bef3
parent164d591df18f1c5b32866b5a69020f6b3cf3b40c (diff)
more Sugar 0.82 compatibility tricks
-rw-r--r--backup.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/backup.py b/backup.py
index 9360aed..077854d 100644
--- a/backup.py
+++ b/backup.py
@@ -130,6 +130,8 @@ class AsyncBackup(gobject.GObject):
self._num_entries = None
self._entries = None
self._data_store = None
+ self._data_store_version = None
+ self._data_store_mount_id = None
self._user_name = profile.get_nick_name().replace('/', ' ')
self._id = self._get_id()
@@ -248,8 +250,8 @@ class AsyncBackup(gobject.GObject):
"""Main program of child."""
try:
self._connect_to_data_store()
- self._entries, self._num_entries = self._find_entries()
- assert self._num_entries == len(self._entries)
+ self._entries = self._find_entries()
+ self._num_entries = len(self._entries)
self._path, self._bundle = self._create_bundle()
for position, entry in enumerate(self._entries):
@@ -392,15 +394,30 @@ class AsyncBackup(gobject.GObject):
self._data_store.find({'uid': 'invalid'}, ['uid'])
logging.info('Data store without version support found')
+ if 'uri' in self._data_store.mounts()[0]:
+ self._data_store_version = 82
+ data_store_path = '/home/olpc/.sugar/default/datastore'
+ self._data_store_mount_id = [mount['id']
+ for mount in self._data_store.mounts()
+ if mount['uri'] == data_store_path][0]
+ logging.info('0.82 data store found')
+ else:
+ logging.info('0.84+ data store without version support found')
+ self._data_store_version = 84
+
def _find_entries(self):
"""Retrieve a list of all entries from the data store."""
if self._data_store.dbus_interface == DS_DBUS_INTERFACE2:
return self._data_store.find({}, {'metadata':
['parent_id', 'tree_id', 'version_id'], 'all_versions': True,
'order_by': ['-timestamp']},
- timeout=5*60, byte_arrays=True)
+ timeout=5*60, byte_arrays=True)[0]
+ elif self._data_store_version == 82:
+ return [entry for entry in self._data_store.find({},
+ ['uid', 'mountpoint'], byte_arrays=True)[0]
+ if entry['mountpoint'] == self._data_store_mount_id]
else:
- return self._data_store.find({}, ['uid'], byte_arrays=True)
+ return self._data_store.find({}, ['uid'], byte_arrays=True)[0]
def _get_metadata(self, object_id):
"""Return metadata for data store entry identified by object_id."""