summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-18 14:25:32 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-18 14:25:32 +0100
commit6c4cdddba85a18bee0bd62d971891ce92e0d2a2d (patch)
treeb60bc6754d6ebf258be44144c4537947ee0026a2 /apps/files
parentcdb1aea809dd0b14271dd4e38ebdb18996dfbff2 (diff)
parentceaefc2c54f4a5d4528bf2e7ba4607297d2453f4 (diff)
downloadnextcloud-server-6c4cdddba85a18bee0bd62d971891ce92e0d2a2d.tar.gz
nextcloud-server-6c4cdddba85a18bee0bd62d971891ce92e0d2a2d.zip
Merge pull request #21610 from owncloud/quota-sharedfile
Fix quota check for single shared files
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/upload.php8
-rw-r--r--apps/files/js/file-upload.js43
2 files changed, 42 insertions, 9 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 5bf69d3e304..36aaed5ad9e 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -136,8 +136,12 @@ $maxUploadFileSize = $storageStats['uploadMaxFilesize'];
$maxHumanFileSize = OCP\Util::humanFileSize($maxUploadFileSize);
$totalSize = 0;
-foreach ($files['size'] as $size) {
- $totalSize += $size;
+$isReceivedShare = \OC::$server->getRequest()->getParam('isReceivedShare', false) === 'true';
+// defer quota check for received shares
+if (!$isReceivedShare) {
+ foreach ($files['size'] as $size) {
+ $totalSize += $size;
+ }
}
if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'),
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index d419cb3a2c0..8ba294e2a7f 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -251,7 +251,26 @@ OC.Upload = {
$('#file_upload_start').trigger(new $.Event('resized'));
},
+ /**
+ * Returns whether the given file is known to be a received shared file
+ *
+ * @param {Object} file file
+ * @return {bool} true if the file is a shared file
+ */
+ _isReceivedSharedFile: function(file) {
+ if (!window.FileList) {
+ return false;
+ }
+ var $tr = window.FileList.findFileEl(file.name);
+ if (!$tr.length) {
+ return false;
+ }
+
+ return ($tr.attr('data-mounttype') === 'shared-root' && $tr.attr('data-mime') !== 'httpd/unix-directory');
+ },
+
init: function() {
+ var self = this;
if ( $('#file_upload_start').exists() ) {
var file_upload_param = {
dropZone: $('#content'), // restrict dropZone to content div
@@ -341,10 +360,15 @@ OC.Upload = {
}
}
- // add size
- selection.totalBytes += file.size;
- // update size of biggest file
- selection.biggestFileBytes = Math.max(selection.biggestFileBytes, file.size);
+ // only count if we're not overwriting an existing shared file
+ if (self._isReceivedSharedFile(file)) {
+ file.isReceivedShare = true;
+ } else {
+ // add size
+ selection.totalBytes += file.size;
+ // update size of biggest file
+ selection.biggestFileBytes = Math.max(selection.biggestFileBytes, file.size);
+ }
// check PHP upload limit against biggest file
if (selection.biggestFileBytes > $('#upload_limit').val()) {
@@ -430,11 +454,16 @@ OC.Upload = {
fileDirectory = data.files[0].relativePath;
}
- addFormData(data.formData, {
+ var params = {
requesttoken: oc_requesttoken,
dir: data.targetDir || FileList.getCurrentDirectory(),
- file_directory: fileDirectory
- });
+ file_directory: fileDirectory,
+ };
+ if (data.files[0].isReceivedShare) {
+ params.isReceivedShare = true;
+ }
+
+ addFormData(data.formData, params);
},
fail: function(e, data) {
OC.Upload.log('fail', e, data);