Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
});
}

Expand Down
2 changes: 2 additions & 0 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,7 @@
mtime: parseInt($el.attr('data-mtime'), 10),
type: $el.attr('data-type'),
etag: $el.attr('data-etag'),
quotaAvailableBytes: $el.attr('data-quota'),
permissions: parseInt($el.attr('data-permissions'), 10),
hasPreview: $el.attr('data-has-preview') === 'true',
isEncrypted: $el.attr('data-e2eencrypted') === 'true'
Expand Down Expand Up @@ -1495,6 +1496,7 @@
"data-mime": mime,
"data-mtime": mtime,
"data-etag": fileData.etag,
"data-quota": fileData.quotaAvailableBytes,
"data-permissions": permissions,
"data-has-preview": fileData.hasPreview !== false,
"data-e2eencrypted": fileData.isEncrypted === true
Expand Down
5 changes: 5 additions & 0 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,7 @@ describe('OCA.Files.FileList tests', function() {
type: 'file',
size: 12,
etag: 'abc',
quotaAvailableBytes: '-1',
permissions: OC.PERMISSION_ALL,
hasPreview: true,
isEncrypted: false
Expand All @@ -2243,6 +2244,7 @@ describe('OCA.Files.FileList tests', function() {
mimetype: 'application/pdf',
mtime: 234560000,
size: 58009,
quotaAvailableBytes: '-1',
etag: '123',
permissions: OC.PERMISSION_ALL,
hasPreview: true,
Expand All @@ -2255,6 +2257,7 @@ describe('OCA.Files.FileList tests', function() {
mimetype: 'httpd/unix-directory',
mtime: 134560000,
size: 250,
quotaAvailableBytes: '-1',
etag: '456',
permissions: OC.PERMISSION_ALL,
hasPreview: true,
Expand All @@ -2278,6 +2281,7 @@ describe('OCA.Files.FileList tests', function() {
mtime: 123456789,
type: 'file',
size: 12,
quotaAvailableBytes: '-1',
etag: 'abc',
permissions: OC.PERMISSION_ALL,
hasPreview: true,
Expand All @@ -2290,6 +2294,7 @@ describe('OCA.Files.FileList tests', function() {
mimetype: 'httpd/unix-directory',
mtime: 134560000,
size: 250,
quotaAvailableBytes: '-1',
etag: '456',
permissions: OC.PERMISSION_ALL,
hasPreview: true,
Expand Down
2 changes: 0 additions & 2 deletions apps/settings/js/vue-settings-apps-819bd91780a5b5e34199.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion core/js/dist/files_client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/files_client.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/files_fileinfo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/files_fileinfo.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions core/src/files/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import escapeHTML from 'escape-html'
Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength'
Client.PROPERTY_ISENCRYPTED = '{' + Client.NS_DAV + '}is-encrypted'
Client.PROPERTY_SHARE_PERMISSIONS = '{' + Client.NS_OCS + '}share-permissions'
Client.PROPERTY_QUOTA_AVAILABLE_BYTES = '{' + Client.NS_DAV + '}quota-available-bytes'

Client.PROTOCOL_HTTP = 'http'
Client.PROTOCOL_HTTPS = 'https'
Expand Down Expand Up @@ -120,6 +121,7 @@ import escapeHTML from 'escape-html'
* File sizes
*/
[Client.NS_DAV, 'getcontentlength'],
[Client.NS_DAV, 'quota-available-bytes'],
/**
* Preview availability
*/
Expand Down Expand Up @@ -397,6 +399,11 @@ import escapeHTML from 'escape-html'
data.mountType = mounTypeProp
}

const quotaAvailableBytes = props['{' + Client.NS_DAV + '}quota-available-bytes']
if (!_.isUndefined(quotaAvailableBytes)) {
data.quotaAvailableBytes = quotaAvailableBytes
}

// extend the parsed data using the custom parsers
_.each(this._fileInfoParsers, function(parserFunction) {
_.extend(data, parserFunction(response, data) || {})
Expand Down
2 changes: 2 additions & 0 deletions core/src/files/fileinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
* @type int
*/
sharePermissions: null,

quotaAvailableBytes: -1,
}

if (!OC.Files) {
Expand Down