Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion www/core/components/settings/controllers/space-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ angular.module('mm.core.settings')
* @todo When "mock site" is implemented we should have functions to calculate the site usage and delete its files.
*/
.controller('mmSettingsSpaceUsageCtrl', function($log, $scope, $mmSitesManager, $mmFS, $q, $mmUtil, $translate,
$mmCourse, $mmText) {
$mmCourse, $mmText, $mmFilepool) {
$log = $log.getInstance('mmSettingsSpaceUsageCtrl');

// Convenience function to calculate each site's usage, and the total usage.
Expand Down Expand Up @@ -107,6 +107,7 @@ angular.module('mm.core.settings')
}).then(function(site) {
return site.deleteFolder().then(function() {
$mmCourse.clearAllModulesStatus(siteid);
$mmFilepool.clearFilepool(siteid);
updateSiteUsage(siteData, 0);
}).catch(function(error) {
if (error && error.code === FileError.NOT_FOUND_ERR) {
Expand Down
15 changes: 15 additions & 0 deletions www/core/lib/filepool.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,21 @@ angular.module('mm.core')
self._processQueue();
};

/**
* Clears the filepool. Use it only when all the files from a site are deleted.
*
* @module mm.core
* @ngdoc method
* @name $mmFilepool#clearFilepool
* @param {String} siteId ID of the site to clear.
* @return {Promise} Promise resolved when the filepool is cleared.
*/
self.clearFilepool = function(siteId) {
return getSiteDb(siteId).then(function(db) {
return db.removeAll(mmFilepoolStore);
});
};

/**
* Returns whether a component has files in the pool.
*
Expand Down