Skip to content

Commit

Permalink
fix: don't use OCP
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf authored Jul 29, 2024
1 parent df236f4 commit 10576ba
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\Util;
use OCP\Server;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -332,17 +331,17 @@ public function rename($source, $target): bool {
$dstParent = dirname($target);

if (!$this->isUpdatable($srcParent)) {
Server:get(LoggerInterface::class)->error('unable to rename, source directory is not writable : ' . $srcParent, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('unable to rename, source directory is not writable : ' . $srcParent, ['app' => 'core']);
return false;
}

if (!$this->isUpdatable($dstParent)) {
Server:get(LoggerInterface::class)->error('unable to rename, destination directory is not writable : ' . $dstParent, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('unable to rename, destination directory is not writable : ' . $dstParent, ['app' => 'core']);
return false;
}

if (!$this->file_exists($source)) {
Server:get(LoggerInterface::class)->error('unable to rename, file does not exists : ' . $source, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('unable to rename, file does not exists : ' . $source, ['app' => 'core']);
return false;
}

Expand Down Expand Up @@ -404,18 +403,18 @@ public function fopen($path, $mode) {
public function hash($type, $path, $raw = false): string|bool {
$sourcePath = $this->getSourcePath($path);
if ($sourcePath === null) {
Server:get(LoggerInterface::class)->error('Source path returned null for path: ' . $sourcePath, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('Source path returned null for path: ' . $sourcePath, ['app' => 'core']);
return false;
}

if (!file_exists($sourcePath) || !is_readable($sourcePath)) {
Server:get(LoggerInterface::class)->error('Source path does not exist or is not readable: ' . $sourcePath, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('Source path does not exist or is not readable: ' . $sourcePath, ['app' => 'core']);
return false;
}

$validAlgorithms = hash_algos();
if (!in_array($type, $validAlgorithms)) {
Server:get(LoggerInterface::class)->error('Invalid hash algorithm: ' . $type, ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error('Invalid hash algorithm: ' . $type, ['app' => 'core']);
return false;
}

Expand Down Expand Up @@ -520,7 +519,7 @@ public function getSourcePath($path) {
return $fullPath;
}

Server:get(LoggerInterface::class)->error("Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", ['app' => 'core']);
\OC::$server->get(LoggerInterface::class)->error("Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", ['app' => 'core']);
throw new ForbiddenException('Following symlinks is not allowed', false);
}

Expand Down

0 comments on commit 10576ba

Please sign in to comment.