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>
This commit is contained in:
parent
e051ef1d68
commit
f9536b0809
|
@ -918,7 +918,7 @@ OC.Uploader.prototype = _.extend({
|
||||||
*/
|
*/
|
||||||
add: function(e, data) {
|
add: function(e, data) {
|
||||||
self.log('add', e, data);
|
self.log('add', e, data);
|
||||||
var that = $(this), freeSpace;
|
var that = $(this), freeSpace = 0;
|
||||||
|
|
||||||
var upload = new OC.FileUpload(self, data);
|
var upload = new OC.FileUpload(self, data);
|
||||||
// can't link directly due to jQuery not liking cyclic deps on its ajax object
|
// 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
|
// 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) {
|
if (freeSpace >= 0 && selection.totalBytes > freeSpace) {
|
||||||
data.textStatus = 'notenoughspace';
|
data.textStatus = 'notenoughspace';
|
||||||
data.errorThrown = t('files',
|
data.errorThrown = t('files',
|
||||||
'Not enough free space, you are uploading {size1} but only {size2} is left', {
|
'Not enough free space, you are uploading {size1} but only {size2} is left', {
|
||||||
'size1': OC.Util.humanFileSize(selection.totalBytes),
|
'size1': OC.Util.humanFileSize(selection.totalBytes),
|
||||||
'size2': OC.Util.humanFileSize($('#free_space').val())
|
'size2': OC.Util.humanFileSize(freeSpace)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1236,6 +1236,7 @@
|
||||||
mtime: parseInt($el.attr('data-mtime'), 10),
|
mtime: parseInt($el.attr('data-mtime'), 10),
|
||||||
type: $el.attr('data-type'),
|
type: $el.attr('data-type'),
|
||||||
etag: $el.attr('data-etag'),
|
etag: $el.attr('data-etag'),
|
||||||
|
quotaAvailableBytes: $el.attr('data-quota'),
|
||||||
permissions: parseInt($el.attr('data-permissions'), 10),
|
permissions: parseInt($el.attr('data-permissions'), 10),
|
||||||
hasPreview: $el.attr('data-has-preview') === 'true',
|
hasPreview: $el.attr('data-has-preview') === 'true',
|
||||||
isEncrypted: $el.attr('data-e2eencrypted') === 'true'
|
isEncrypted: $el.attr('data-e2eencrypted') === 'true'
|
||||||
|
@ -1495,6 +1496,7 @@
|
||||||
"data-mime": mime,
|
"data-mime": mime,
|
||||||
"data-mtime": mtime,
|
"data-mtime": mtime,
|
||||||
"data-etag": fileData.etag,
|
"data-etag": fileData.etag,
|
||||||
|
"data-quota": fileData.quotaAvailableBytes,
|
||||||
"data-permissions": permissions,
|
"data-permissions": permissions,
|
||||||
"data-has-preview": fileData.hasPreview !== false,
|
"data-has-preview": fileData.hasPreview !== false,
|
||||||
"data-e2eencrypted": fileData.isEncrypted === true
|
"data-e2eencrypted": fileData.isEncrypted === true
|
||||||
|
|
|
@ -2238,6 +2238,7 @@ describe('OCA.Files.FileList tests', function() {
|
||||||
type: 'file',
|
type: 'file',
|
||||||
size: 12,
|
size: 12,
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
|
quotaAvailableBytes: '-1',
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
hasPreview: true,
|
hasPreview: true,
|
||||||
isEncrypted: false
|
isEncrypted: false
|
||||||
|
@ -2249,6 +2250,7 @@ describe('OCA.Files.FileList tests', function() {
|
||||||
mimetype: 'application/pdf',
|
mimetype: 'application/pdf',
|
||||||
mtime: 234560000,
|
mtime: 234560000,
|
||||||
size: 58009,
|
size: 58009,
|
||||||
|
quotaAvailableBytes: '-1',
|
||||||
etag: '123',
|
etag: '123',
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
hasPreview: true,
|
hasPreview: true,
|
||||||
|
@ -2261,6 +2263,7 @@ describe('OCA.Files.FileList tests', function() {
|
||||||
mimetype: 'httpd/unix-directory',
|
mimetype: 'httpd/unix-directory',
|
||||||
mtime: 134560000,
|
mtime: 134560000,
|
||||||
size: 250,
|
size: 250,
|
||||||
|
quotaAvailableBytes: '-1',
|
||||||
etag: '456',
|
etag: '456',
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
hasPreview: true,
|
hasPreview: true,
|
||||||
|
@ -2284,6 +2287,7 @@ describe('OCA.Files.FileList tests', function() {
|
||||||
mtime: 123456789,
|
mtime: 123456789,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
size: 12,
|
size: 12,
|
||||||
|
quotaAvailableBytes: '-1',
|
||||||
etag: 'abc',
|
etag: 'abc',
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
hasPreview: true,
|
hasPreview: true,
|
||||||
|
@ -2296,6 +2300,7 @@ describe('OCA.Files.FileList tests', function() {
|
||||||
mimetype: 'httpd/unix-directory',
|
mimetype: 'httpd/unix-directory',
|
||||||
mtime: 134560000,
|
mtime: 134560000,
|
||||||
size: 250,
|
size: 250,
|
||||||
|
quotaAvailableBytes: '-1',
|
||||||
etag: '456',
|
etag: '456',
|
||||||
permissions: OC.PERMISSION_ALL,
|
permissions: OC.PERMISSION_ALL,
|
||||||
hasPreview: true,
|
hasPreview: true,
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue