From 34e20927c4210e517dcd7dfc3c2a703b06f12904 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 02 Mar 2009 17:09:18 +0000 Subject: Check the activity version and replace an older version upon download #464 --- (limited to 'src') diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index 4f4d320..4ca751c 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -277,12 +277,13 @@ class JournalActivity(Window): return if registry.is_installed(bundle): + logging.debug('_check_for_bundle bundle already installed') return try: registry.install(bundle) - except (ZipExtractException, RegistrationException), e: - logging.warning('Could not install bundle %s: %r' % - (bundle.get_path(), e)) + except (ZipExtractException, RegistrationException): + logging.warning('Could not install bundle %s:\n%s' % \ + (bundle.get_path(), traceback.format_exc())) return if metadata['mime_type'] == JournalEntryBundle.MIME_TYPE: diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py index ee440a5..57db287 100644 --- a/src/jarabe/model/bundleregistry.py +++ b/src/jarabe/model/bundleregistry.py @@ -208,7 +208,7 @@ class BundleRegistry(gobject.GObject): ''.join(traceback.format_exception(*sys.exc_info())))) return None - if self.get_bundle(bundle.get_bundle_id()) is not None: + if self.is_installed(bundle): return None self._bundles.append(bundle) @@ -305,13 +305,26 @@ class BundleRegistry(gobject.GObject): open(path, 'w').write(cjson.encode(favorites_data)) def is_installed(self, bundle): - return self.get_bundle(bundle.get_bundle_id()) is not None + for installed_bundle in self._bundles: + if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \ + bundle.get_activity_version() == \ + installed_bundle.get_activity_version(): + return True + return False def install(self, bundle): activities_path = env.get_user_activities_path() if self.is_installed(bundle): raise AlreadyInstalledException + for installed_bundle in self._bundles: + if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \ + bundle.get_activity_version() == \ + installed_bundle.get_activity_version(): + raise AlreadyInstalledException + elif bundle.get_bundle_id() == installed_bundle.get_bundle_id(): + self.uninstall(installed_bundle, force=True) + install_dir = env.get_user_activities_path() install_path = bundle.install(install_dir) -- cgit v0.9.1