Skip to content

Commit

Permalink
only get logger when needed in sabre/directory
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 18, 2023
1 parent 80b001f commit f0b70e5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,19 @@ public function delete() {
}
}

private function getLogger(): LoggerInterface {
return \OC::$server->get(LoggerInterface::class);
}

/**
* Returns available diskspace information
*
* @return array
*/
public function getQuotaInfo() {
/** @var LoggerInterface $logger */
$logger = \OC::$server->get(LoggerInterface::class);
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");
$this->getLogger()->warning("error while getting quota as the relative path cannot be found");
return [0, 0];
}

Expand All @@ -345,13 +344,13 @@ public function getQuotaInfo() {
];
return $this->quotaInfo;
} catch (\OCP\Files\NotFoundException $e) {
$logger->warning("error while getting quota into", ['exception' => $e]);
$this->getLogger()->warning("error while getting quota into", ['exception' => $e]);
return [0, 0];
} catch (\OCP\Files\StorageNotAvailableException $e) {
$logger->warning("error while getting quota into", ['exception' => $e]);
$this->getLogger()->warning("error while getting quota into", ['exception' => $e]);
return [0, 0];
} catch (NotPermittedException $e) {
$logger->warning("error while getting quota into", ['exception' => $e]);
$this->getLogger()->warning("error while getting quota into", ['exception' => $e]);
return [0, 0];
}
}
Expand Down

0 comments on commit f0b70e5

Please sign in to comment.