Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#955 closed defect (fixed)

mimetype database only updated when installing activities

Reported by: erikos Owned by: tomeu
Priority: Unspecified by Maintainer Milestone:
Component: Sugar Version: 0.84.x
Severity: Major Keywords: r+
Cc: Distribution/OS: Unspecified
Bug Status: New


The code to read in the activity/imetypes.xml lives in sugar/bundle/ActivityBundle.install This is only executed when installing an activity.

When one unzip a .xo into ~/Activities (when running Sugar) the mimetype is not added to the database. There is some code in jarabe/model/ to monitor those folders for changes. We could call the mimetype adding there.

Another case is, when sugar is not running (emulator for example) and one places an activity in the ~/Activity folder. This should ideally be handled as well.

Change History (3)

comment:1 Changed 15 years ago by erikos

  • Keywords r? added
diff --git a/src/sugar/bundle/ b/src/sugar/bundle/
index 268576e..1c00dea 100644
--- a/src/sugar/bundle/
+++ b/src/sugar/bundle/
@@ -311,7 +311,15 @@ class ActivityBundle(Bundle):
                 raise MalformedBundleException(err)
+        self.install_myme_type(install_path)
+        return install_path
+    def install_mime_type(self, install_path):
+        ''' Update the mime type database and
+            install the mime type icon
+        '''
         xdg_data_home = os.getenv('XDG_DATA_HOME',
@@ -347,7 +355,6 @@ class ActivityBundle(Bundle):
-        return install_path
     def uninstall(self, install_path, force=False):
         if os.path.islink(install_path):
@@ -355,7 +362,7 @@ class ActivityBundle(Bundle):
             # because we may be removing user data.
         xdg_data_home = os.getenv('XDG_DATA_HOME',

Move the mime-database-update function out of the install one.

diff --git a/src/jarabe/model/ b/src/jarabe/model/
index 068cf8d..7c758eb 100644
--- a/src/jarabe/model/
+++ b/src/jarabe/model/
@@ -78,7 +78,7 @@ class BundleRegistry(gobject.GObject):
         if not one_file.get_path().endswith('.activity'):
         if event_type == gio.FILE_MONITOR_EVENT_CREATED:
-            self.add_bundle(one_file.get_path())
+            self.add_bundle(one_file.get_path(), monitor=True)
         elif event_type == gio.FILE_MONITOR_EVENT_DELETED:
@@ -194,8 +194,8 @@ class BundleRegistry(gobject.GObject):
                 logging.error('Error while processing installed activity ' \
                               'bundle: %s, %s, %s' % (folder, e.__class__, e))
-    def add_bundle(self, bundle_path):
-        bundle = self._add_bundle(bundle_path)
+    def add_bundle(self, bundle_path, monitor=False):
+        bundle = self._add_bundle(bundle_path, monitor)
         if bundle is not None:
@@ -205,10 +205,12 @@ class BundleRegistry(gobject.GObject):
             return False
-    def _add_bundle(self, bundle_path):
+    def _add_bundle(self, bundle_path, monitor=False):
         logging.debug('STARTUP: Adding bundle %r' % bundle_path)
             bundle = ActivityBundle(bundle_path)
+            if monitor is True:
+                bundle.install_mime_type(bundle_path)
         except MalformedBundleException:

update mime-database on new folder detection.

comment:2 Changed 15 years ago by tomeu

  • Keywords r+ added; r? removed
  • Resolution set to fixed
  • Status changed from new to closed

Pushed, thanks!

comment:3 Changed 11 years ago by dnarvaez

  • Milestone 0.86 deleted

Milestone 0.86 deleted

Note: See TracTickets for help on using tickets.