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 08:44:30 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-09-13 08:44:30 (GMT)
commite41ae62da584578f1a8ccd627db575bf30ba84b6 (patch)
tree23cadc0d39b7fc1a2e6748b7cba785a8a1f070f1
parent5cf7406d43b2ac59bee4013b68385722a3374ae6 (diff)
add support for Sugar 0.82 data store
-rw-r--r--restore.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/restore.py b/restore.py
index ebfe505..e8c73c0 100644
--- a/restore.py
+++ b/restore.py
@@ -140,6 +140,7 @@ class AsyncRestore(gobject.GObject):
self._pipe_to_child = None
self._pipe_from_child_watch_id = None
self._data_store = None
+ self._data_store_version = None
def start(self):
"""Start the restore process."""
@@ -328,6 +329,7 @@ class AsyncRestore(gobject.GObject):
data_fd, data_file_name = tempfile.mkstemp(prefix='Restore',
dir=self._tmp_dir)
data_file = os.fdopen(data_fd, 'w')
+ os.chmod(data_file_name, 0640)
try:
# TODO: handle large files better (i.e. use external tool)
# TODO: predict disk-full
@@ -402,6 +404,7 @@ class AsyncRestore(gobject.GObject):
DS_DBUS_PATH2), DS_DBUS_INTERFACE2)
self._data_store.find({'tree_id': 'invalid'},
{'metadata': ['tree_id']}, timeout=DS_DBUS_SIMPLE_FIND_TIMEOUT)
+ self._data_store_version = 1000
logging.info('Data store with version support found')
return
@@ -412,7 +415,12 @@ class AsyncRestore(gobject.GObject):
DS_DBUS_PATH1), DS_DBUS_INTERFACE1)
self._data_store.find({'uid': 'invalid'}, ['uid'],
timeout=DS_DBUS_SIMPLE_FIND_TIMEOUT)
- logging.info('Data store without version support found')
+ if 'uri' in self._data_store.mounts()[0]:
+ self._data_store_version = 82
+ logging.info('0.82 data store found')
+ else:
+ logging.info('0.84+ data store without version support found')
+ self._data_store_version = 84
def _save_entry(self, metadata, data_path):
"""Store object in data store."""
@@ -452,8 +460,15 @@ class AsyncRestore(gobject.GObject):
# workaround for SL#1590
metadata['timestamp'] = str(int(timestamp))
- self._data_store.update(uid, metadata, data_path, True,
- timeout=DS_DBUS_SAVE_TIMEOUT)
+
+ if self._data_store_version == 82:
+ metadata['uid'] = uid
+ metadata.pop('mountpoint', None)
+ self._data_store.create(metadata, data_path, True,
+ timeout=DS_DBUS_SAVE_TIMEOUT)
+ else:
+ self._data_store.update(uid, metadata, data_path, True,
+ timeout=DS_DBUS_SAVE_TIMEOUT)
def _find_entry_v1(self, uid):
"""Retrieve given entry from v1 data store if it exists.