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

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

    From 339e4e25734d9d68119f16f2f87c019e31d58830 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 others 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..f6d52ee 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, delete_profile=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 delete_profile:
     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):