summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-05-18 21:09:17 +0200
committerGitHub <noreply@github.com>2018-05-18 21:09:17 +0200
commit03a6f8e14e63a0abcf4ed8fbca12998bcbb59be3 (patch)
treefa8d8d9dfd4ea390134a8cf69d54a5c18172750e /lib
parent9cc15bc9b0372b34c909d7000ba801d258f64019 (diff)
parent32fd0919c1fc546bf84b5ce2da54dd59c57f4085 (diff)
downloadnextcloud-server-03a6f8e14e63a0abcf4ed8fbca12998bcbb59be3.tar.gz
nextcloud-server-03a6f8e14e63a0abcf4ed8fbca12998bcbb59be3.zip
Merge pull request #9490 from marco44/faster_large_filehelper_32bits
Make LargeFileHelper.php faster by avoiding execs as much as possible
Diffstat (limited to 'lib')
-rwxr-xr-x[-rw-r--r--]lib/private/LargeFileHelper.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/private/LargeFileHelper.php b/lib/private/LargeFileHelper.php
index ea848f83622..d6dcbeedb48 100644..100755
--- a/lib/private/LargeFileHelper.php
+++ b/lib/private/LargeFileHelper.php
@@ -117,7 +117,7 @@ class LargeFileHelper {
public function getFileSizeViaCurl($fileName) {
if (\OC::$server->getIniWrapper()->getString('open_basedir') === '') {
$encodedFileName = rawurlencode($fileName);
- $ch = curl_init("file://$encodedFileName");
+ $ch = curl_init("file:///$encodedFileName");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
@@ -185,14 +185,22 @@ class LargeFileHelper {
* @return int
*/
public function getFileMtime($fullPath) {
- if (\OC_Helper::is_function_enabled('exec')) {
- $os = strtolower(php_uname('s'));
- if (strpos($os, 'linux') !== false) {
- return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));
+ try {
+ $result = filemtime($fullPath);
+ } catch (\Exception $e) {
+ $result =- 1;
+ }
+ if ($result < 0) {
+ if (\OC_Helper::is_function_enabled('exec')) {
+ $os = strtolower(php_uname('s'));
+ if (strpos($os, 'linux') !== false) {
+ return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));
+ }
}
}
+ return $result;
+
- return filemtime($fullPath);
}
protected function exec($cmd) {