diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2011-07-15 17:14:02 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2011-07-15 17:14:02 (GMT) |
commit | f472ad829c3ac4a836f9606e622b0d25759f8c0d (patch) | |
tree | ccb59684c57cc78dbcc658e66b996b48c08133b2 /downloadmanager.py | |
parent | fe2c95f950c3d8e654eadb4c85ba38031b7cd049 (diff) |
Remove unfinished downloads
When Browse starts removes all files in the instance directory that where not modified in a long time(1 day).
Since there is no way to pause a download and continue later, this files are failed downloads that should be eliminated.
this is the ''cache'' case of an already fixed issue, by Jose Prous joseprous@gmail.com
Diffstat (limited to 'downloadmanager.py')
-rw-r--r-- | downloadmanager.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/downloadmanager.py b/downloadmanager.py index 4eab726..4adf98d 100644 --- a/downloadmanager.py +++ b/downloadmanager.py @@ -56,6 +56,8 @@ DS_DBUS_PATH = '/org/laptop/sugar/DataStore' _MIN_TIME_UPDATE = 5 # In seconds _MIN_PERCENT_UPDATE = 10 +_MAX_DELTA_CACHE_TIME = 86400 # In seconds + _active_downloads = [] _dest_to_window = {} @@ -75,6 +77,15 @@ def remove_all_downloads(): datastore.delete(download.dl_jobject.object_id) download.cleanup() +def remove_old_parts(): + temp_path = os.path.join(activity.get_activity_root(), 'instance') + if os.path.exists(temp_path): + for file in os.listdir(temp_path): + file_full_path = os.path.join(temp_path, file) + modification_time = os.path.getmtime(file_full_path) + if(time.time() - modification_time > _MAX_DELTA_CACHE_TIME): + logging.debug('removing %s' % file_full_path) + os.remove(file_full_path) class HelperAppLauncherDialog: _com_interfaces_ = interfaces.nsIHelperAppLauncherDialog |