Update quotas on each upload

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-01-03 13:59:36 +01:00
parent a8ab67ff48
commit c4490c6ba8
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
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(true);
});
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.