From c4490c6ba890240777fc033b56f9bdd8fd4f4c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 3 Jan 2018 13:59:36 +0100 Subject: [PATCH 1/2] Update quotas on each upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 6 ++++++ apps/files/js/files.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index d0c0fc1a7f..a2fd45e24b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -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)); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a1e59015b1..5e34f664a6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -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. From 51eb26e18379a2ba3f90c719048fc2d3986f3190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 3 Jan 2018 14:01:47 +0100 Subject: [PATCH 2/2] Fix unwanted var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a2fd45e24b..5e17f128a7 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -3080,7 +3080,7 @@ uploadText.fadeOut(); uploadText.attr('currentUploads', 0); - self.updateStorageQuotas(true); + self.updateStorageQuotas(); }); uploader.on('createdfolder', function(fullPath) { self.addAndFetchFileInfo(OC.basename(fullPath), OC.dirname(fullPath));