Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-08-25 17:17:37 +0400
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-08-25 17:17:37 +0400
commit96430a99f9cc550f15e7ff1894ddda48f7581cc3 (patch)
treef25ca19496d470abb53d945ba8ca49dfc085143d
parenteb276df08cf478124e4421af1e18f88ed9d3d434 (diff)
parent8f0d89a98663fa0d5ce889515a3a6c9dc5fd55d1 (diff)
Merge pull request #10448 from owncloud/check_quota_on_new_via_web_stable6
check quota when trying to download a file via new -> web
-rw-r--r--apps/files/ajax/newfile.php39
-rw-r--r--apps/files/lib/helper.php3
2 files changed, 39 insertions, 3 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index c327d2b9f94..4943f8793af 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -82,9 +82,41 @@ if($source) {
exit();
}
+ if (!ini_get('allow_url_fopen')) {
+ $eventSource->send('error', $l10n->t('Server is not allowed to open URLs, please check the server configuration'));
+ $eventSource->close();
+ exit();
+ }
+
$ctx = stream_context_create(null, array('notification' =>'progress'));
- $sourceStream=fopen($source, 'rb', false, $ctx);
- $result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
+ $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', (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) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
$mime=$meta['mimetype'];
@@ -93,6 +125,9 @@ if($source) {
} else {
$eventSource->send('error', $l10n->t('Error while downloading %s to %s', array($source, $target)));
}
+ if (is_resource($sourceStream)) {
+ fclose($sourceStream);
+ }
$eventSource->close();
exit();
} else {
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index eaff28178ea..8c7f2d26ef0 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -15,7 +15,8 @@ class Helper
return array('uploadMaxFilesize' => $maxUploadFilesize,
'maxHumanFilesize' => $maxHumanFilesize,
- 'usedSpacePercent' => (int)$storageInfo['relative']);
+ 'usedSpacePercent' => (int)$storageInfo['relative'],
+ 'freeSpace' => (int)$storageInfo['free']);
}
public static function determineIcon($file) {