Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-03-02 17:09:18 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-03-02 17:09:18 (GMT)
commit34e20927c4210e517dcd7dfc3c2a703b06f12904 (patch)
treec134b3d0aad1ae49ae6a371ea2eeb194639ea20c /src
parent58a1ab968b51748bd3460570eb05617fbedc6807 (diff)
Check the activity version and replace an older version upon download #464
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/journal/journalactivity.py7
-rw-r--r--src/jarabe/model/bundleregistry.py17
2 files changed, 19 insertions, 5 deletions
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)