Skip to content

Commit

Permalink
Revert now unnecessary changes
Browse files Browse the repository at this point in the history
This reverts the following commits:
* fb0045d
* 9a557bf
* 50216ef
  • Loading branch information
taminob committed Nov 23, 2023
1 parent c17656c commit 46cdd0d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 66 deletions.
50 changes: 0 additions & 50 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,56 +192,6 @@ public function createDirectory($name) {
}
}

/**
* Creates a new symlink
*
* @param string $name
* @param string $target
* @return null|string
* @throws FileLocked
* @throws InvalidPath
* @throws ServiceUnavailable
* @throws \Sabre\DAV\Exception
* @throws \Sabre\DAV\Exception\Forbidden
*/
public function createSymlink($name, $target) {
try {
if (!$this->info->isCreatable()) {
throw new \Sabre\DAV\Exception\Forbidden();
}

$this->fileView->verifyPath($this->path, $name);

[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
if (!$storage || !$storage->instanceOfStorage(\OC\Files\Storage\Local::class)) {
throw new \Sabre\DAV\Exception\NotImplemented("Symlinks currently not supported on non-local storages - failed to create '$name'!");
}

$internalPath = $internalPath . '/' . $name;
$storage->unlink($internalPath);
if (!$storage->symlink($target, $internalPath)) {
throw new \Sabre\DAV\Exception\Forbidden("Could not create symlink '$name'!");
}
$storage->getUpdater()->update($internalPath);
$newEtag = $storage->getETag($internalPath);
$infoData = [
'type' => FileInfo::TYPE_FILE,
'etag' => $newEtag,
];
$path = \OC\Files\Filesystem::normalizePath($this->path . '/' . $name);
$this->fileView->putFileInfo($path, $infoData);
return '"' . $newEtag . '"';
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new ServiceUnavailable($e->getMessage(), $e->getCode(), $e);
} catch (InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage(), false, $ex);
} catch (ForbiddenException $ex) {
throw new Forbidden($ex->getMessage(), $ex->getRetry(), $ex);
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
}

/**
* Returns a specific child node, referenced by its name
*
Expand Down
17 changes: 1 addition & 16 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ public function is_file($path) {
return is_file($this->getSourcePath($path));
}

public function is_link($path) {
return is_link($this->getSourcePath($path));
}

public function stat($path) {
$fullPath = $this->getSourcePath($path);
clearstatcache(true, $fullPath);
Expand Down Expand Up @@ -341,21 +337,10 @@ public function file_put_contents($path, $data) {
return $result;
}

/**
* create symlink
*
* @param string $path
* @param string $target
* @return bool
*/
public function symlink($target, $path) {
return symlink($target, $this->getSourcePath($path));
}

public function unlink($path) {
if ($this->is_dir($path)) {
return $this->rmdir($path);
} elseif ($this->is_file($path) || $this->is_link($path)) {
} elseif ($this->is_file($path)) {
return unlink($this->getSourcePath($path));
} else {
return false;
Expand Down

0 comments on commit 46cdd0d

Please sign in to comment.