From cd616ec1d17f78a217a819e6164c90603a8c34c7 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Mon, 13 Sep 2010 19:02:57 +0000 Subject: more Sugar 0.82 compatibility tricks --- 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.""" -- cgit v0.9.1