summaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-11-13 12:46:12 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-17 09:43:44 +0100
commitf9536b08096ed1c80391af36d33a18198be1fced (patch)
tree392bab69b73d2046f082d5205c34214002dc34d6 /apps/files/js/file-upload.js
parente051ef1d686721e8ccbedab9ee92b5876f206800 (diff)
downloadnextcloud-server-f9536b08096ed1c80391af36d33a18198be1fced.tar.gz
nextcloud-server-f9536b08096ed1c80391af36d33a18198be1fced.zip
Check for target folder available quota when uploading
Signed-off-by: Julius Härtl <jus@bitgrid.net> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 691131293a8..3c0ca319225 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -918,7 +918,7 @@ OC.Uploader.prototype = _.extend({
*/
add: function(e, data) {
self.log('add', e, data);
- var that = $(this), freeSpace;
+ var that = $(this), freeSpace = 0;
var upload = new OC.FileUpload(self, data);
// can't link directly due to jQuery not liking cyclic deps on its ajax object
@@ -989,13 +989,20 @@ OC.Uploader.prototype = _.extend({
}
// check free space
- freeSpace = $('#free_space').val();
+ if (!self.fileList || upload.getTargetFolder() === self.fileList.getCurrentDirectory()) {
+ // Use global free space if there is no file list to check or the current directory is the target
+ freeSpace = $('#free_space').val()
+ } else if (upload.getTargetFolder().indexOf(self.fileList.getCurrentDirectory()) === 0) {
+ // Check subdirectory free space if file is uploaded there
+ var targetSubdir = upload._targetFolder.replace(self.fileList.getCurrentDirectory(), '')
+ freeSpace = parseInt(upload.uploader.fileList.getModelForFile(targetSubdir).get('quotaAvailableBytes'))
+ }
if (freeSpace >= 0 && selection.totalBytes > freeSpace) {
data.textStatus = 'notenoughspace';
data.errorThrown = t('files',
'Not enough free space, you are uploading {size1} but only {size2} is left', {
'size1': OC.Util.humanFileSize(selection.totalBytes),
- 'size2': OC.Util.humanFileSize($('#free_space').val())
+ 'size2': OC.Util.humanFileSize(freeSpace)
});
}