Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
tweak(Tinebase/WebDAV): only return sabredav exceptions
Browse files Browse the repository at this point in the history
... in createFile()

Change-Id: I7958161791992cc6065fb2ea08d5ec33287fafbb
Reviewed-on: http://gerrit.tine20.com/customers/18235
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
  • Loading branch information
pschuele committed Oct 20, 2020
1 parent cc09fe5 commit 8e83383
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tine20/Tinebase/Frontend/WebDAV/Directory.php
Expand Up @@ -94,9 +94,8 @@ public function childExists($name)
* @throws Sabre\DAV\Exception\Forbidden
* @throws Sabre\DAV\Exception\NotFound
* @throws Sabre\DAV\Exception\InsufficientStorage
* @throws Sabre\DAV\Exception
* @return string
*
* TODO only throw Sabre\DAV\Exception\*?
*/
public function createFile($name, $data = null)
{
Expand All @@ -121,12 +120,16 @@ public function createFile($name, $data = null)

$name = $completeFile->name;
if (false === ($data = fopen($completeFile->path, 'r'))) {
throw new Tinebase_Exception_Backend('fopen on temp file path failed ' . $completeFile->path);
throw new Sabre\DAV\Exception('fopen on temp file path failed ' . $completeFile->path);
}
}

if ($this->childExists($name)) {
return $this->getChild($name)->put($data);
try {
return $this->getChild($name)->put($data);
} catch (Tinebase_Exception_NotFound $tenf) {
throw new Sabre\DAV\Exception\NotFound($tenf->getMessage());
}
}

$path = $this->_path . '/' . $name;
Expand All @@ -143,14 +146,14 @@ public function createFile($name, $data = null)

if (is_resource($data)) {
if (false === stream_copy_to_stream($data, $handle)) {
throw new Tinebase_Exception_Backend('stream_copy_to_stream failed');
throw new Sabre\DAV\Exception('stream_copy_to_stream failed');
}
} else {
throw new Tinebase_Exception_UnexpectedValue('data should be a resource');
throw new Sabre\DAV\Exception('data should be a resource');
}

if (true !== Tinebase_FileSystem::getInstance()->fclose($handle)) {
throw new Tinebase_Exception_Backend('Tinebase_FileSystem::fclose failed for path ' . $path);
throw new Sabre\DAV\Exception('Tinebase_FileSystem::fclose failed for path ' . $path);
}


Expand All @@ -162,7 +165,7 @@ public function createFile($name, $data = null)
} else if ($e instanceof Tinebase_Exception_NotFound) {
throw new Sabre\DAV\Exception\NotFound($e->getMessage());
} else {
throw $e;
throw new Sabre\DAV\Exception($e->getMessage());
}
}

Expand Down

0 comments on commit 8e83383

Please sign in to comment.