Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2009-11-26 15:45:27 (GMT)
committer Daniel Drake <dsd@laptop.org>2009-11-26 15:45:27 (GMT)
commitd83d3fce34c86a617cb6524e00c3383cece15222 (patch)
tree7a3c4e969672458253de0fa7f3499a2921aee28f /src
parentbd3fdd73a853d618aa5000ff5b1ce82f196c8b70 (diff)
Journal entry bundles shouldn't create a 2nd ds entry
This fixes a problem where "Show in Journal" from a Browse download was broken. This is because the JEB installation code would extract the content from the bundle entry, install it as a new datastore entry, and then delete the bundle entry. This is fixed by making the journal entry from the bundle take over the datastore entry that belonged to the bundle.
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/journal/journalactivity.py16
-rw-r--r--src/jarabe/journal/journalentrybundle.py10
-rw-r--r--src/jarabe/model/bundleregistry.py9
3 files changed, 23 insertions, 12 deletions
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
index 0d6d09d..0559560 100644
--- a/src/jarabe/journal/journalactivity.py
+++ b/src/jarabe/journal/journalactivity.py
@@ -276,16 +276,24 @@ class JournalActivity(Window):
if registry.is_installed(bundle):
logging.debug('_check_for_bundle bundle already installed')
return
+
+ if metadata['mime_type'] == JournalEntryBundle.MIME_TYPE:
+ # JournalEntryBundle code takes over the datastore entry and
+ # transforms it into the journal entry from the bundle -- we have
+ # nothing more to do.
+ try:
+ registry.install(bundle, metadata['uid'])
+ except (ZipExtractException, RegistrationException):
+ logging.exception('Could not install bundle %s',
+ bundle.get_path())
+ return
+
try:
registry.install(bundle)
except (ZipExtractException, RegistrationException):
logging.exception('Could not install bundle %s', bundle.get_path())
return
- if metadata['mime_type'] == JournalEntryBundle.MIME_TYPE:
- model.delete(object_id)
- return
-
metadata['bundle_id'] = bundle.get_bundle_id()
model.write(metadata)
diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
index 74b2ac5..9e68c06 100644
--- a/src/jarabe/journal/journalentrybundle.py
+++ b/src/jarabe/journal/journalentrybundle.py
@@ -40,24 +40,24 @@ class JournalEntryBundle(Bundle):
def __init__(self, path):
Bundle.__init__(self, path)
- def install(self, install_path):
+ def install(self, install_path, uid=''):
if os.environ.has_key('SUGAR_ACTIVITY_ROOT'):
install_dir = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],
'data')
else:
install_dir = tempfile.gettempdir()
bundle_dir = os.path.join(install_dir, self._zip_root_dir)
- uid = self._zip_root_dir
+ temp_uid = self._zip_root_dir
self._unzip(install_dir)
try:
metadata = self._read_metadata(bundle_dir)
- metadata['uid'] = ''
+ metadata['uid'] = uid
- preview = self._read_preview(uid, bundle_dir)
+ preview = self._read_preview(temp_uid, bundle_dir)
if preview is not None:
metadata['preview'] = dbus.ByteArray(preview)
- file_path = os.path.join(bundle_dir, uid)
+ file_path = os.path.join(bundle_dir, temp_uid)
model.write(metadata, file_path)
finally:
shutil.rmtree(bundle_dir, ignore_errors=True)
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index aa49c72..60b2ab9 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -338,7 +338,7 @@ class BundleRegistry(gobject.GObject):
return True
return False
- def install(self, bundle):
+ def install(self, bundle, uid=None):
activities_path = env.get_user_activities_path()
for installed_bundle in self._bundles:
@@ -350,8 +350,11 @@ class BundleRegistry(gobject.GObject):
self.uninstall(installed_bundle, force=True)
install_dir = env.get_user_activities_path()
- install_path = bundle.install(install_dir)
-
+ if isinstance(bundle, JournalEntryBundle):
+ install_path = bundle.install(install_dir, uid)
+ else:
+ install_path = bundle.install(install_dir)
+
# TODO treat ContentBundle in special way
# needs rethinking while fixing ContentBundle support
if isinstance(bundle, ContentBundle) or \