Merge pull request #7681 from nextcloud/fix-quota-update-2

Update quotas on each upload
This commit is contained in:
Morris Jobke 2018-01-03 16:30:19 +01:00 committed by GitHub
commit 0bc6a7d7fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -1802,6 +1802,10 @@
OCA.Files.Files.updateStorageStatistics(this.getCurrentDirectory(), force);
},
updateStorageQuotas: function() {
OCA.Files.Files.updateStorageQuotas(this.getCurrentDirectory());
},
/**
* @deprecated do not use nor override
*/
@ -3075,6 +3079,8 @@
self.showFileBusyState(uploadText.closest('tr'), false);
uploadText.fadeOut();
uploadText.attr('currentUploads', 0);
self.updateStorageQuotas();
});
uploader.on('createdfolder', function(fullPath) {
self.addAndFetchFileInfo(OC.basename(fullPath), OC.dirname(fullPath));

View File

@ -32,6 +32,23 @@
Files.updateQuota(response);
});
},
// update quota
updateStorageQuotas: function(currentDir) {
var state = Files.updateStorageStatistics;
if (state.dir){
if (state.dir === currentDir) {
return;
}
// cancel previous call, as it was for another dir
state.call.abort();
}
state.dir = currentDir;
state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {
state.dir = null;
state.call = null;
Files.updateQuota(response);
});
},
/**
* Update storage statistics such as free space, max upload,
* etc based on the given directory.