diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-08-08 17:32:50 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-08-08 17:32:50 +0200 |
commit | 7b6b99f55a2400527f77ddedbd18d97e3723773f (patch) | |
tree | 7a056ad45beed6d4e9330089875780774d33b179 | |
parent | 6dd7d9e0af3c4c1ce62e77e0932fdebe80175d16 (diff) | |
parent | c24957565c71a0bf3706d0ae86d67f0d9c40dcde (diff) | |
download | nextcloud-server-7b6b99f55a2400527f77ddedbd18d97e3723773f.tar.gz nextcloud-server-7b6b99f55a2400527f77ddedbd18d97e3723773f.zip |
Merge pull request #10290 from owncloud/check_quota_on_new_via_web
check quota when trying to download a file via new -> web
-rw-r--r-- | apps/files/ajax/newfile.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index 7d6be59beab..9cfe51a6218 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -108,6 +108,29 @@ if($source) { $sourceStream=@fopen($source, 'rb', false, $ctx); $result = 0; if (is_resource($sourceStream)) { + $meta = stream_get_meta_data($sourceStream); + if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data'])) { + //check stream size + $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); + $freeSpace = $storageStats['freeSpace']; + + foreach($meta['wrapper_data'] as $header) { + list($name, $value) = explode(':', $header); + if ('content-length' === strtolower(trim($name))) { + $length = (int) trim($value); + + if ($length > $freeSpace) { + $delta = $length - $freeSpace; + $humanDelta = OCP\Util::humanFileSize($delta); + + $eventSource->send('error', array('message' => (string)$l10n->t('The file exceeds your quota by %s', array($humanDelta)))); + $eventSource->close(); + fclose($sourceStream); + exit(); + } + } + } + } $result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream); } if($result) { |