|
|
@ -59,12 +59,13 @@ class Local extends \OC\Files\Storage\Common { |
|
|
if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { |
|
|
if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { |
|
|
throw new \InvalidArgumentException('No data directory set for local storage'); |
|
|
throw new \InvalidArgumentException('No data directory set for local storage'); |
|
|
} |
|
|
} |
|
|
$this->datadir = $arguments['datadir']; |
|
|
|
|
|
|
|
|
$this->datadir = str_replace('//', '/', $arguments['datadir']); |
|
|
// some crazy code uses a local storage on root...
|
|
|
// some crazy code uses a local storage on root...
|
|
|
if ($this->datadir === '/') { |
|
|
if ($this->datadir === '/') { |
|
|
$this->realDataDir = $this->datadir; |
|
|
$this->realDataDir = $this->datadir; |
|
|
} else { |
|
|
} else { |
|
|
$this->realDataDir = rtrim(realpath($this->datadir), '/') . '/'; |
|
|
|
|
|
|
|
|
$realPath = realpath($this->datadir) ?: $this->datadir; |
|
|
|
|
|
$this->realDataDir = rtrim($realPath, '/') . '/'; |
|
|
} |
|
|
} |
|
|
if (substr($this->datadir, -1) !== '/') { |
|
|
if (substr($this->datadir, -1) !== '/') { |
|
|
$this->datadir .= '/'; |
|
|
$this->datadir .= '/'; |
|
|
@ -361,14 +362,18 @@ class Local extends \OC\Files\Storage\Common { |
|
|
*/ |
|
|
*/ |
|
|
public function getSourcePath($path) { |
|
|
public function getSourcePath($path) { |
|
|
$fullPath = $this->datadir . $path; |
|
|
$fullPath = $this->datadir . $path; |
|
|
if ($this->allowSymlinks || $path === '') { |
|
|
|
|
|
|
|
|
$currentPath = $path; |
|
|
|
|
|
if ($this->allowSymlinks || $currentPath === '') { |
|
|
return $fullPath; |
|
|
return $fullPath; |
|
|
} |
|
|
} |
|
|
$pathToResolve = $fullPath; |
|
|
$pathToResolve = $fullPath; |
|
|
$realPath = realpath($pathToResolve); |
|
|
$realPath = realpath($pathToResolve); |
|
|
while ($realPath === false) { // for non existing files check the parent directory
|
|
|
while ($realPath === false) { // for non existing files check the parent directory
|
|
|
$pathToResolve = dirname($pathToResolve); |
|
|
|
|
|
$realPath = realpath($pathToResolve); |
|
|
|
|
|
|
|
|
$currentPath = dirname($currentPath); |
|
|
|
|
|
if ($currentPath === '' || $currentPath === '.') { |
|
|
|
|
|
return $fullPath; |
|
|
|
|
|
} |
|
|
|
|
|
$realPath = realpath($this->datadir . $currentPath); |
|
|
} |
|
|
} |
|
|
if ($realPath) { |
|
|
if ($realPath) { |
|
|
$realPath = $realPath . '/'; |
|
|
$realPath = $realPath . '/'; |
|
|
|