Skip to content

Commit 8382629

Browse files
committed
MOBILE-1313 filepool: Clear filepool when site files are deleted
1 parent 4e15e43 commit 8382629

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

www/core/components/settings/controllers/space-usage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('mm.core.settings')
2323
* @todo When "mock site" is implemented we should have functions to calculate the site usage and delete its files.
2424
*/
2525
.controller('mmSettingsSpaceUsageCtrl', function($log, $scope, $mmSitesManager, $mmFS, $q, $mmUtil, $translate,
26-
$mmCourse, $mmText) {
26+
$mmCourse, $mmText, $mmFilepool) {
2727
$log = $log.getInstance('mmSettingsSpaceUsageCtrl');
2828

2929
// Convenience function to calculate each site's usage, and the total usage.
@@ -107,6 +107,7 @@ angular.module('mm.core.settings')
107107
}).then(function(site) {
108108
return site.deleteFolder().then(function() {
109109
$mmCourse.clearAllModulesStatus(siteid);
110+
$mmFilepool.clearFilepool(siteid);
110111
updateSiteUsage(siteData, 0);
111112
}).catch(function(error) {
112113
if (error && error.code === FileError.NOT_FOUND_ERR) {

www/core/lib/filepool.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,21 @@ angular.module('mm.core')
414414
self._processQueue();
415415
};
416416

417+
/**
418+
* Clears the filepool. Use it only when all the files from a site are deleted.
419+
*
420+
* @module mm.core
421+
* @ngdoc method
422+
* @name $mmFilepool#clearFilepool
423+
* @param {String} siteId ID of the site to clear.
424+
* @return {Promise} Promise resolved when the filepool is cleared.
425+
*/
426+
self.clearFilepool = function(siteId) {
427+
return getSiteDb(siteId).then(function(db) {
428+
return db.removeAll(mmFilepoolStore);
429+
});
430+
};
431+
417432
/**
418433
* Returns whether a component has files in the pool.
419434
*

0 commit comments

Comments
 (0)