Ticket #1499: actutils.patch

File actutils.patch, 2.0 KB (added by dsd, 15 years ago)

patch against bitfrost/update/actutils.py

  • actutils.py

    From: Daniel Drake <dsd@laptop.org>
    
    BundleHelper: Support bundles on the filesystem, and add helper code to
    complete the incremental update process
    
    old new class BundleHelper(object): 
    100100    """This class helps with the installation/upgrade of activity and
    101101    content bundles."""
    102102    def __init__(self, filename):
     103        if os.path.isdir(filename):
     104            self._init_dir(filename)
     105        else:
     106            self._init_zip(filename)
     107
     108    def _init_dir(self, dirname):
     109        # check for a activity.info file to determine whether this is an
     110        # activity or content bundle.
     111        if os.path.exists("%s/activity/activity.info" % dirname):
     112            self.bundle = ActivityBundle(dirname)
     113            self.is_activity = True
     114        else:
     115            self.bundle = ContentBundle(dirname)
     116            self.is_activity = False
     117
     118    def _init_zip(self, filename):
    103119        # check for a activity.info file to determine whether this is an
    104120        # activity or content bundle.
    105121        zf = ZipFile(filename)
    class BundleHelper(object): 
    161177            self._activity_install_or_upgrade(registry)
    162178        else:
    163179            self._library_install_or_upgrade()
     180
     181    def handle_inplace_upgrade(self, registry, old_path):
     182        """Perform any post-upgrade tasks needed when an activity has been
     183        updated in-place on the filesystem."""
     184        if not self.is_activity:
     185            # just regenerate the index
     186            self.bundle._run_indexer()
     187            return
     188
     189        # update activity registry
     190        fav = registry.get_activity(self.bundle.get_bundle_id()).favorite
     191        registry.remove_bundle(old_path)
     192        registry.add_bundle(self.bundle.get_path())
     193        registry.set_activity_favorite(self.bundle.get_bundle_id(),
     194                                       self.bundle.get_activity_version(),
     195                                       fav)
     196