diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-30 16:13:48 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-30 16:13:48 +0200 |
commit | 31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2 (patch) | |
tree | 3981e3c1b7fc001c38971856bbc050b5c041167d /lib/private/files/storage/local.php | |
parent | 2ba5701b1af3ba37061fa0e5fa85aac7abaabea4 (diff) | |
parent | 129d8099b948c0b5c7456af42cf9a618f5f6920d (diff) | |
download | nextcloud-server-31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2.tar.gz nextcloud-server-31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2.zip |
Merge pull request #5365 from owncloud/filesize-improvements-32bit
Add LargeFileHelper / Add CURL filesize workaround / Fix some 32-bit filesize issues
Diffstat (limited to 'lib/private/files/storage/local.php')
-rw-r--r-- | lib/private/files/storage/local.php | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 943c4163088..e33747bbd52 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -89,11 +89,10 @@ if (\OC_Util::runningOnWindows()) { public function stat($path) { $fullPath = $this->datadir . $path; $statResult = stat($fullPath); - - if ($statResult['size'] < 0) { - $size = self::getFileSizeFromOS($fullPath); - $statResult['size'] = $size; - $statResult[7] = $size; + if (PHP_INT_SIZE === 4 && !$this->is_dir($path)) { + $filesize = $this->filesize($path); + $statResult['size'] = $filesize; + $statResult[7] = $filesize; } return $statResult; } @@ -109,15 +108,13 @@ if (\OC_Util::runningOnWindows()) { public function filesize($path) { if ($this->is_dir($path)) { return 0; - } else { - $fullPath = $this->datadir . $path; - $fileSize = filesize($fullPath); - if ($fileSize < 0) { - return self::getFileSizeFromOS($fullPath); - } - - return $fileSize; } + $fullPath = $this->datadir . $path; + if (PHP_INT_SIZE === 4) { + $helper = new \OC\LargeFileHelper; + return $helper->getFilesize($fullPath); + } + return filesize($fullPath); } public function isReadable($path) { @@ -220,35 +217,6 @@ if (\OC_Util::runningOnWindows()) { return $return; } - /** - * @param string $fullPath - */ - private static function getFileSizeFromOS($fullPath) { - $name = strtolower(php_uname('s')); - // Windows OS: we use COM to access the filesystem - if (strpos($name, 'win') !== false) { - if (class_exists('COM')) { - $fsobj = new \COM("Scripting.FileSystemObject"); - $f = $fsobj->GetFile($fullPath); - return $f->Size; - } - } else if (strpos($name, 'bsd') !== false) { - if (\OC_Helper::is_function_enabled('exec')) { - return (float)exec('stat -f %z ' . escapeshellarg($fullPath)); - } - } else if (strpos($name, 'linux') !== false) { - if (\OC_Helper::is_function_enabled('exec')) { - return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); - } - } else { - \OC_Log::write('core', - 'Unable to determine file size of "' . $fullPath . '". Unknown OS: ' . $name, - \OC_Log::ERROR); - } - - return 0; - } - public function hash($type, $path, $raw = false) { return hash_file($type, $this->datadir . $path, $raw); } |