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

File 0001-Delete-activities-profile-data-when-uninstall.patch.5, 1.9 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
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
11More infomation at http://bugs.sugarlabs.org/ticket/2074
12
13Signed-off-by: Martin Abente <mabente@paraguayeduca.org>
14---
15 src/sugar/bundle/activitybundle.py |    9 ++++++++-
16 1 files changed, 8 insertions(+), 1 deletions(-)
17
18diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
19index 673db67..c5111e0 100644
20--- a/src/sugar/bundle/activitybundle.py
21+++ b/src/sugar/bundle/activitybundle.py
22@@ -23,6 +23,7 @@ UNSTABLE.
23 from ConfigParser import ConfigParser
24 import locale
25 import os
26+import shutil
27 import tempfile
28 import logging
29 import warnings
30@@ -393,7 +394,7 @@ class ActivityBundle(Bundle):
31             os.unlink(dst)
32         os.symlink(src, dst)
33 
34-    def uninstall(self, install_path, force=False):
35+    def uninstall(self, install_path, force=False, delete_profile=False):
36         if os.path.islink(install_path):
37             # Don't remove the actual activity dir if it's a symbolic link
38             # because we may be removing user data.
39@@ -422,6 +423,12 @@ class ActivityBundle(Bundle):
40                        os.readlink(path).startswith(install_path):
41                         os.remove(path)
42 
43+        if delete_profile:
44+            bundle_profile_path = env.get_profile_path(self._bundle_id)
45+            if os.path.exists(bundle_profile_path):
46+                os.chmod(bundle_profile_path, 0775)
47+                shutil.rmtree(bundle_profile_path, ignore_errors=True)
48+
49         self._uninstall(install_path)
50 
51     def is_user_activity(self):
52--
531.6.0.4
54