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

File 0001-Delete-activities-profile-data-when-uninstall.patch.6, 1.8 KB (added by tch, 11 years ago)
Line 
1From c3b3b9fd3b8c624ffb4fa5ee2af6adc4fe3bf571 Mon Sep 17 00:00:00 2001
2From: Martin Abente <mabente@paraguayeduca.org>
3Date: Wed, 18 Aug 2010 10:22:49 -0400
4Subject: [PATCH] Delete activities profile data when uninstall #2074
5Organization: Paraguay Educa
6
7When activities are uninstalled, profile data persists. Profile
8data can consume a lot of storage space. Therefore it is necessary
9to delete it when required.
10
11Signed-off-by: Martin Abente <mabente@paraguayeduca.org>
12---
13 src/sugar/bundle/activitybundle.py |    9 ++++++++-
14 1 files changed, 8 insertions(+), 1 deletions(-)
15
16diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
17index 673db67..c5111e0 100644
18--- a/src/sugar/bundle/activitybundle.py
19+++ b/src/sugar/bundle/activitybundle.py
20@@ -23,6 +23,7 @@ UNSTABLE.
21 from ConfigParser import ConfigParser
22 import locale
23 import os
24+import shutil
25 import tempfile
26 import logging
27 import warnings
28@@ -393,7 +394,7 @@ class ActivityBundle(Bundle):
29             os.unlink(dst)
30         os.symlink(src, dst)
31 
32-    def uninstall(self, install_path, force=False):
33+    def uninstall(self, install_path, force=False, delete_profile=False):
34         if os.path.islink(install_path):
35             # Don't remove the actual activity dir if it's a symbolic link
36             # because we may be removing user data.
37@@ -422,6 +423,12 @@ class ActivityBundle(Bundle):
38                        os.readlink(path).startswith(install_path):
39                         os.remove(path)
40 
41+        if delete_profile:
42+            bundle_profile_path = env.get_profile_path(self._bundle_id)
43+            if os.path.exists(bundle_profile_path):
44+                os.chmod(bundle_profile_path, 0775)
45+                shutil.rmtree(bundle_profile_path, ignore_errors=True)
46+
47         self._uninstall(install_path)
48 
49     def is_user_activity(self):
50--
511.6.0.4
52