[Pkg-owncloud-commits] [owncloud] 58/121: check quota when trying to download a file via new -> web
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 16:44:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit c8f81e6241a23fbb57bf4499c6dcfe24c35a7d24
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date: Fri Aug 8 14:35:33 2014 +0200
check quota when trying to download a file via new -> web
---
apps/files/ajax/newfile.php | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 7d6be59..9cfe51a 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) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list