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 {
->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);
->method('getMountPoint')
->willReturn($mountPoint);
+ $this->view->expects($this->any())
+ ->method('getRelativePath')
+ ->willReturn('/foo');
+
$mountPoint->method('getMountPoint')
->willReturn('/user/files/mymountpoint');
$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
}
* get path relative to the root of the view
*
* @param string $path
- * @return string
+ * @return ?string
*/
public function getRelativePath($path) {
$this->assertPathLength($path);
* 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()) {
if (!$view) {
throw new \OCP\Files\NotFoundException();
}
- $fullPath = $view->getAbsolutePath($path);
+ $fullPath = Filesystem::normalizePath($view->getAbsolutePath($path));
$cacheKey = $fullPath. '::' . ($includeMountPoints ? 'include' : 'exclude');
if ($useCache) {
/** @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');
}
/**