[Bugs] #955 UNSP: mimetype database only updated when installing activities

SugarLabs Bugs bugtracker-noreply at sugarlabs.org
Fri Jun 12 07:12:26 EDT 2009


#955: mimetype database only updated when installing activities
------------------------------------------+---------------------------------
    Reporter:  erikos                     |          Owner:  tomeu      
        Type:  defect                     |         Status:  new        
    Priority:  Unspecified by Maintainer  |      Milestone:  0.86       
   Component:  sugar                      |        Version:  0.84.x     
    Severity:  Major                      |     Resolution:             
    Keywords:  r?                         |   Distribution:  Unspecified
Status_field:  New                        |  
------------------------------------------+---------------------------------
Changes (by erikos):

  * keywords:  => r?


Comment:

 {{{
 diff --git a/src/sugar/bundle/activitybundle.py
 b/src/sugar/bundle/activitybundle.py
 index 268576e..1c00dea 100644
 --- a/src/sugar/bundle/activitybundle.py
 +++ b/src/sugar/bundle/activitybundle.py
 @@ -311,7 +311,15 @@ class ActivityBundle(Bundle):
                  raise MalformedBundleException(err)
              else:
                  logging.warning(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',
                                    os.path.expanduser('~/.local/share'))

 @@ -347,7 +355,6 @@ class ActivityBundle(Bundle):
                      os.symlink(info_file,
                                 os.path.join(installed_icons_dir,
                                              os.path.basename(info_file)))
 -        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.
              os.unlink(install_path)
              return
 -
 +
          xdg_data_home = os.getenv('XDG_DATA_HOME',
                                    os.path.expanduser('~/.local/share'))
 }}}

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

 {{{
 diff --git a/src/jarabe/model/bundleregistry.py
 b/src/jarabe/model/bundleregistry.py
 index 068cf8d..7c758eb 100644
 --- a/src/jarabe/model/bundleregistry.py
 +++ b/src/jarabe/model/bundleregistry.py
 @@ -78,7 +78,7 @@ class BundleRegistry(gobject.GObject):
          if not one_file.get_path().endswith('.activity'):
              return
          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:
              self.remove_bundle(one_file.get_path())

 @@ -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:
              self._set_bundle_favorite(bundle.get_bundle_id(),
                                        bundle.get_activity_version(),
 @@ -205,10 +205,12 @@ class BundleRegistry(gobject.GObject):
          else:
              return False

 -    def _add_bundle(self, bundle_path):
 +    def _add_bundle(self, bundle_path, monitor=False):
          logging.debug('STARTUP: Adding bundle %r' % bundle_path)
          try:
              bundle = ActivityBundle(bundle_path)
 +            if monitor is True:
 +                bundle.install_mime_type(bundle_path)
          except MalformedBundleException:
 :
 }}}

 update mime-database on new folder detection.

-- 
Ticket URL: <http://dev.sugarlabs.org/ticket/955#comment:1>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list