From b68dac19b1e85b0a5765ab80b95baa408f9dc8f8 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Mon, 6 Apr 2009 11:01:55 +0000
Subject: Let user upgrade system activity from .xo #701

---
 src/jarabe/model/bundleregistry.py |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index d23d5cb..29f0733 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -210,8 +210,18 @@ class BundleRegistry(gobject.GObject):
                 ''.join(traceback.format_exception(*sys.exc_info()))))
             return None
 
-        if self.is_installed(bundle):
-            return None
+        installed = self.get_bundle(bundle.get_bundle_id())
+
+        if installed:
+            if installed.get_activity_version() >= \
+                    bundle.get_activity_version():
+                logging.debug('STARTUP: Skip old version for %s' % \
+                bundle.get_bundle_id())
+                return installed
+            else:
+                logging.debug('STARTUP: Re-using newest activity %s' % \
+                        bundle.get_bundle_id())
+                self.remove_bundle(bundle_path)
 
         self._bundles.append(bundle)
         return bundle
@@ -357,14 +367,14 @@ class BundleRegistry(gobject.GObject):
                 act.get_activity_version() != bundle.get_activity_version():
             logging.warning('Not uninstalling, different bundle present')
             return
-        elif not act.get_path().startswith(env.get_user_activities_path()):
-            logging.warning('Not uninstalling system activity')
-            return
 
         install_path = act.get_path()
 
-        bundle.uninstall(install_path, force)
-        
+        if not install_path.startswith(env.get_user_activities_path()):
+            logging.warning('Not uninstalling system activity')
+        else:  
+            bundle.uninstall(install_path, force)
+
         if not self.remove_bundle(install_path):
             raise RegistrationException
 
-- 
1.6.2

