diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-05-12 18:49:25 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-05-18 10:15:17 +0200 |
commit | 887be709f5f0dbbc6ad7b1cc1a9793d04421c5b9 (patch) | |
tree | 15cfcb45871688ecd6208f461b0d1e25171a917f /lib/private/files.php | |
parent | 73a3086945b41afa39debd89481c021934dedb67 (diff) | |
download | nextcloud-server-887be709f5f0dbbc6ad7b1cc1a9793d04421c5b9.tar.gz nextcloud-server-887be709f5f0dbbc6ad7b1cc1a9793d04421c5b9.zip |
a new approach to display the error message
Diffstat (limited to 'lib/private/files.php')
-rw-r--r-- | lib/private/files.php | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/lib/private/files.php b/lib/private/files.php index 97f9d8163b1..6a739fc844c 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -129,52 +129,60 @@ class OC_Files { $zip = new ZipStreamer(false); } OC_Util::obEnd(); - if ($zip or \OC\Files\Filesystem::isReadable($filename)) { - self::sendHeaders($filename, $name, $zip); - } elseif (!\OC\Files\Filesystem::file_exists($filename)) { - header("HTTP/1.0 404 Not Found"); - $tmpl = new OC_Template('', '404', 'guest'); - $tmpl->printPage(); - } else { - header("HTTP/1.0 403 Forbidden"); - die('403 Forbidden'); - } - if($only_header) { - return ; - } - if ($zip) { - $executionTime = intval(ini_get('max_execution_time')); - set_time_limit(0); - if ($get_type === self::ZIP_FILES) { - foreach ($files as $file) { - $file = $dir . '/' . $file; - if (\OC\Files\Filesystem::is_file($file)) { - $fh = \OC\Files\Filesystem::fopen($file, 'r'); - $zip->addFileFromStream($fh, basename($file)); - fclose($fh); - } elseif (\OC\Files\Filesystem::is_dir($file)) { - self::zipAddDir($file, $zip); + + try { + + if ($zip or \OC\Files\Filesystem::isReadable($filename)) { + self::sendHeaders($filename, $name, $zip); + } elseif (!\OC\Files\Filesystem::file_exists($filename)) { + header("HTTP/1.0 404 Not Found"); + $tmpl = new OC_Template('', '404', 'guest'); + $tmpl->printPage(); + } else { + header("HTTP/1.0 403 Forbidden"); + die('403 Forbidden'); + } + if ($only_header) { + return; + } + if ($zip) { + $executionTime = intval(ini_get('max_execution_time')); + set_time_limit(0); + if ($get_type === self::ZIP_FILES) { + foreach ($files as $file) { + $file = $dir . '/' . $file; + if (\OC\Files\Filesystem::is_file($file)) { + $fh = \OC\Files\Filesystem::fopen($file, 'r'); + $zip->addFileFromStream($fh, basename($file)); + fclose($fh); + } elseif (\OC\Files\Filesystem::is_dir($file)) { + self::zipAddDir($file, $zip); + } } + } elseif ($get_type === self::ZIP_DIR) { + $file = $dir . '/' . $files; + self::zipAddDir($file, $zip); } - } elseif ($get_type === self::ZIP_DIR) { - $file = $dir . '/' . $files; - self::zipAddDir($file, $zip); - } - $zip->finalize(); - set_time_limit($executionTime); - } else { - if ($xsendfile) { - $view = \OC\Files\Filesystem::getView(); - /** @var $storage \OC\Files\Storage\Storage */ - list($storage) = $view->resolvePath($filename); - if ($storage->isLocal()) { - self::addSendfileHeader($filename); + $zip->finalize(); + set_time_limit($executionTime); + } else { + if ($xsendfile) { + $view = \OC\Files\Filesystem::getView(); + /** @var $storage \OC\Files\Storage\Storage */ + list($storage) = $view->resolvePath($filename); + if ($storage->isLocal()) { + self::addSendfileHeader($filename); + } else { + \OC\Files\Filesystem::readfile($filename); + } } else { \OC\Files\Filesystem::readfile($filename); } - } else { - \OC\Files\Filesystem::readfile($filename); } + } catch (\Exception $ex) { + $l = \OC::$server->getL10N('core'); + $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; + \OC_Template::printErrorPage($l->t('Can\'t read file'), $hint); } } |