diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-08-08 14:35:33 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-08-08 14:35:33 +0200 |
commit | c24957565c71a0bf3706d0ae86d67f0d9c40dcde (patch) | |
tree | 77279863cdb2a5b8346349c884c1907a54bad653 /apps | |
parent | fa260b1649e200a0e6a4d3d921bcf22c414d4824 (diff) | |
download | nextcloud-server-c24957565c71a0bf3706d0ae86d67f0d9c40dcde.tar.gz nextcloud-server-c24957565c71a0bf3706d0ae86d67f0d9c40dcde.zip |
check quota when trying to download a file via new -> web
Diffstat (limited to 'apps')
-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) { |