Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/model/bundleregistry.py
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/jarabe/model/bundleregistry.py
parent58a1ab968b51748bd3460570eb05617fbedc6807 (diff)
Check the activity version and replace an older version upon download #464
Diffstat (limited to 'src/jarabe/model/bundleregistry.py')
-rw-r--r--src/jarabe/model/bundleregistry.py17
1 files changed, 15 insertions, 2 deletions
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)