Ticket #2074: 0001-Delete-activities-profile-data-when-uninstall.2.patch

File 0001-Delete-activities-profile-data-when-uninstall.2.patch, 1.9 KB (added by tch, 11 years ago)
  • src/sugar/bundle/activitybundle.py

    From 7986905d78fdc28daea082f741a2463b38bb8918 Mon Sep 17 00:00:00 2001
    From: Martin Abente <mabente@paraguayeduca.org>
    Date: Tue, 6 Jul 2010 11:55:50 -0400
    Subject: [PATCH] Delete activities profile data when uninstall
    Organization: Paraguay Educa
    
    When activities are uninstalled, profile data persists. Profile
    data can consume a lot of disk space. Therefore it is necessary
    to delete it.
    
    This patch add a new parameter to activitybundle uninstall method
    to differentiate the delete and upgrade scenarios.
    
    More info at http://bugs.sugarlabs.org/ticket/2074
    
    Signed-off-by: Martin Abente <mabente@paraguayeduca.org>
    ---
     src/sugar/bundle/activitybundle.py |    9 ++++++++-
     1 files changed, 8 insertions(+), 1 deletions(-)
    
    diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
    index c83257f..260e565 100644
    a b import locale 
    2525import os
    2626import tempfile
    2727import logging
     28import shutil
    2829
    2930from sugar import env
    3031from sugar import util
    class ActivityBundle(Bundle): 
    388389            os.unlink(dst)
    389390        os.symlink(src, dst)
    390391
    391     def uninstall(self, install_path, force=False):
     392    def uninstall(self, install_path, force=False, upgrade=False):
    392393        if os.path.islink(install_path):
    393394            # Don't remove the actual activity dir if it's a symbolic link
    394395            # because we may be removing user data.
    class ActivityBundle(Bundle): 
    417418                       os.readlink(path).startswith(install_path):
    418419                        os.remove(path)
    419420
     421        if not upgrade:
     422            bundle_profile_path = env.get_profile_path(self._bundle_id)
     423            if os.path.exists(bundle_profile_path):
     424                os.chmod(bundle_profile_path, 0775)
     425                shutil.rmtree(bundle_profile_path, ignore_errors=True)
     426
    420427        self._uninstall(install_path)
    421428
    422429    def is_user_activity(self):