1 | From c3b3b9fd3b8c624ffb4fa5ee2af6adc4fe3bf571 Mon Sep 17 00:00:00 2001 |
---|
2 | From: Martin Abente <mabente@paraguayeduca.org> |
---|
3 | Date: Wed, 18 Aug 2010 10:22:49 -0400 |
---|
4 | Subject: [PATCH] Delete activities profile data when uninstall #2074 |
---|
5 | Organization: Paraguay Educa |
---|
6 | |
---|
7 | When activities are uninstalled, profile data persists. Profile |
---|
8 | data can consume a lot of storage space. Therefore it is necessary |
---|
9 | to delete it when required. |
---|
10 | |
---|
11 | Signed-off-by: Martin Abente <mabente@paraguayeduca.org> |
---|
12 | --- |
---|
13 | src/sugar/bundle/activitybundle.py | 9 ++++++++- |
---|
14 | 1 files changed, 8 insertions(+), 1 deletions(-) |
---|
15 | |
---|
16 | diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py |
---|
17 | index 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 | -- |
---|
51 | 1.6.0.4 |
---|
52 | |
---|