]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update quota value in client after scan and upload
authorVincent Petry <pvince81@owncloud.com>
Wed, 6 Nov 2013 09:15:05 +0000 (10:15 +0100)
committerVincent Petry <pvince81@owncloud.com>
Wed, 6 Nov 2013 09:15:05 +0000 (10:15 +0100)
After uploading, the quota value wasn't refreshed.
This fix refreshes the quota value after files have been scanned or
uploaded.

apps/files/js/file-upload.js
apps/files/js/filelist.js
apps/files/js/files.js

index 94290895ebd103f19b76d1247584ff0eb7586e36..553ca036360a66214513b3363f8f5e09d4cd3d7b 100644 (file)
@@ -404,7 +404,7 @@ $(document).ready(function() {
                                
                                $('#uploadprogresswrapper input.stop').fadeOut();
                                $('#uploadprogressbar').fadeOut();
-                               
+                           Files.updateStorageStatistics();
                        });
                        fileupload.on('fileuploadfail', function(e, data) {
                                OC.Upload.log('progress handle fileuploadfail', e, data);
index 3ef3c2c1766b9a2b80c16cf2934d7deef3c9ea48..66b4a006f8869fc308af6fcb692b88e278863227 100644 (file)
@@ -554,6 +554,7 @@ var FileList={
                                                checkTrashStatus();
                                                FileList.updateFileSummary();
                                                FileList.updateEmptyContent();
+                                               Files.updateStorageStatistics();
                                        } else {
                                                $.each(files,function(index,file) {
                                                        var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete");
index eb30ddfda0f7e03ff19763a560f19bf71befc21b..a7aea0957bdc7870c84e30fa09721f1bc32dc656 100644 (file)
@@ -1,4 +1,28 @@
 Files={
+       // file space size sync
+       _updateStorageStatistics: function() {
+               Files._updateStorageStatisticsTimeout = null;
+               if (Files.updateStorageStatistics.running){
+                       return;
+               }
+               Files.updateStorageStatistics.running = true;
+               $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
+                       Files.updateStorageStatistics.running = false;
+                       Files.updateMaxUploadFilesize(response);
+               });
+       },
+       updateStorageStatistics: function() {
+               if (!OC.currentUser) {
+                       return;
+               }
+
+               // debounce to prevent calling too often
+               if (Files._updateStorageStatisticsTimeout) {
+                       clearTimeout(Files._updateStorageStatisticsTimeout);
+               }
+               Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 1000);
+       },
+
        updateMaxUploadFilesize:function(response) {
                if (response === undefined) {
                        return;
@@ -351,29 +375,23 @@ $(document).ready(function() {
        setTimeout ( "Files.displayStorageWarnings()", 100 );
        OC.Notification.setDefault(Files.displayStorageWarnings);
 
-       // file space size sync
-       function update_storage_statistics() {
-               $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
-                       Files.updateMaxUploadFilesize(response);
-               });
-       }
        // only possible at the moment if user is logged in
        if (OC.currentUser) {
                // start on load - we ask the server every 5 minutes
-               var update_storage_statistics_interval = 5*60*1000;
-               var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+               var updateStorageStatisticsInterval = 5*60*1000;
+               var updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
 
                // Use jquery-visibility to de-/re-activate file stats sync
                if ($.support.pageVisibility) {
                        $(document).on({
                                'show.visibility': function() {
-                                       if (!update_storage_statistics_interval_id) {
-                                               update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+                                       if (!updateStorageStatisticsIntervalId) {
+                                               updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
                                        }
                                },
                                'hide.visibility': function() {
-                                       clearInterval(update_storage_statistics_interval_id);
-                                       update_storage_statistics_interval_id = 0;
+                                       clearInterval(updateStorageStatisticsIntervalId);
+                                       updateStorageStatisticsIntervalId = 0;
                                }
                        });
                }
@@ -417,6 +435,7 @@ function scanFiles(force, dir, users) {
        scannerEventSource.listen('done',function(count) {
                scanFiles.scanning=false;
                console.log('done after ' + count + ' files');
+               Files.updateStorageStatistics();
        });
        scannerEventSource.listen('user',function(user) {
                console.log('scanning files for ' + user);