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 |
25 | 25 | import os |
26 | 26 | import tempfile |
27 | 27 | import logging |
| 28 | import shutil |
28 | 29 | |
29 | 30 | from sugar import env |
30 | 31 | from sugar import util |
… |
… |
class ActivityBundle(Bundle): |
388 | 389 | os.unlink(dst) |
389 | 390 | os.symlink(src, dst) |
390 | 391 | |
391 | | def uninstall(self, install_path, force=False): |
| 392 | def uninstall(self, install_path, force=False, delete_profile=False): |
392 | 393 | if os.path.islink(install_path): |
393 | 394 | # Don't remove the actual activity dir if it's a symbolic link |
394 | 395 | # because we may be removing user data. |
… |
… |
class ActivityBundle(Bundle): |
417 | 418 | os.readlink(path).startswith(install_path): |
418 | 419 | os.remove(path) |
419 | 420 | |
| 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 | |
420 | 427 | self._uninstall(install_path) |
421 | 428 | |
422 | 429 | def is_user_activity(self): |