mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 23:59:27 -04:00
fix: Use proper path for quota fetching
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
3287eddbbc
commit
d515da502f
4 changed files with 25 additions and 7 deletions
|
|
@ -325,8 +325,14 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
|
|||
if ($this->quotaInfo) {
|
||||
return $this->quotaInfo;
|
||||
}
|
||||
$relativePath = $this->fileView->getRelativePath($this->info->getPath());
|
||||
if ($relativePath === null) {
|
||||
$logger->warning("error while getting quota as the relative path cannot be found");
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
try {
|
||||
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info, false);
|
||||
$storageInfo = \OC_Helper::getStorageInfo($relativePath, $this->info, false);
|
||||
if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
|
||||
$free = \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -304,6 +304,10 @@ class DirectoryTest extends \Test\TestCase {
|
|||
->method('free_space')
|
||||
->willReturn(800);
|
||||
|
||||
$this->info->expects($this->any())
|
||||
->method('getPath')
|
||||
->willReturn('/admin/files/foo');
|
||||
|
||||
$this->info->expects($this->once())
|
||||
->method('getSize')
|
||||
->willReturn(200);
|
||||
|
|
@ -312,6 +316,10 @@ class DirectoryTest extends \Test\TestCase {
|
|||
->method('getMountPoint')
|
||||
->willReturn($mountPoint);
|
||||
|
||||
$this->view->expects($this->any())
|
||||
->method('getRelativePath')
|
||||
->willReturn('/foo');
|
||||
|
||||
$mountPoint->method('getMountPoint')
|
||||
->willReturn('/user/files/mymountpoint');
|
||||
|
||||
|
|
@ -359,6 +367,10 @@ class DirectoryTest extends \Test\TestCase {
|
|||
$mountPoint->method('getMountPoint')
|
||||
->willReturn('/user/files/mymountpoint');
|
||||
|
||||
$this->view->expects($this->any())
|
||||
->method('getRelativePath')
|
||||
->willReturn('/foo');
|
||||
|
||||
$dir = new Directory($this->view, $this->info);
|
||||
$this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class View {
|
|||
* get path relative to the root of the view
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getRelativePath($path) {
|
||||
$this->assertPathLength($path);
|
||||
|
|
@ -1241,7 +1241,7 @@ class View {
|
|||
* get the path relative to the default root for hook usage
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
private function getHookPath($path) {
|
||||
if (!Filesystem::getView()) {
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ class OC_Helper {
|
|||
if (!$view) {
|
||||
throw new \OCP\Files\NotFoundException();
|
||||
}
|
||||
$fullPath = $view->getAbsolutePath($path);
|
||||
$fullPath = Filesystem::normalizePath($view->getAbsolutePath($path));
|
||||
|
||||
$cacheKey = $fullPath. '::' . ($includeMountPoints ? 'include' : 'exclude');
|
||||
if ($useCache) {
|
||||
|
|
@ -624,9 +624,9 @@ class OC_Helper {
|
|||
/** @var ICacheFactory $cacheFactory */
|
||||
$cacheFactory = \OC::$server->get(ICacheFactory::class);
|
||||
$memcache = $cacheFactory->createLocal('storage_info');
|
||||
$cacheKey = Filesystem::normalizePath($absolutePath) . '::';
|
||||
$memcache->remove($cacheKey . 'include');
|
||||
$memcache->remove($cacheKey . 'exclude');
|
||||
$cacheKeyPrefix = Filesystem::normalizePath($absolutePath) . '::';
|
||||
$memcache->remove($cacheKeyPrefix . 'include');
|
||||
$memcache->remove($cacheKeyPrefix . 'exclude');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue