summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/file.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-05-29 09:59:20 +0200
committerRobin Appelman <icewind@owncloud.com>2015-06-01 13:22:57 +0200
commitba174ac626ae54b75565870fdeb55398436599e4 (patch)
tree4e5adebcd21eba19604c98c64ec4b6450506d146 /lib/private/connector/sabre/file.php
parent8665a98744a8d3545859b809fc479ea216e45176 (diff)
downloadnextcloud-server-ba174ac626ae54b75565870fdeb55398436599e4.tar.gz
nextcloud-server-ba174ac626ae54b75565870fdeb55398436599e4.zip
Convert LockedException to FileLocked in Sabre connector
For Sabre to be able to return the proper error code instead of 500, the LockedException is now rethrown as FileLocked exception in the Sabre connector
Diffstat (limited to 'lib/private/connector/sabre/file.php')
-rw-r--r--lib/private/connector/sabre/file.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 325206f060b..3e1b29a4f28 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -46,6 +46,7 @@ use OCP\Files\LockNotAcquiredException;
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
use OCP\Lock\ILockingProvider;
+use OCP\Lock\LockedException;
use Sabre\DAV\Exception;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\Forbidden;
@@ -80,6 +81,7 @@ class File extends Node implements IFile {
* @throws Exception
* @throws EntityTooLarge
* @throws ServiceUnavailable
+ * @throws FileLocked
* @return string|null
*/
public function put($data) {
@@ -111,7 +113,11 @@ class File extends Node implements IFile {
$partFilePath = $this->path;
}
- $this->fileView->lockFile($this->path, ILockingProvider::LOCK_EXCLUSIVE);
+ try {
+ $this->fileView->lockFile($this->path, ILockingProvider::LOCK_EXCLUSIVE);
+ } catch (LockedException $e) {
+ throw new FileLocked($e->getMessage(), $e->getCode(), $e);
+ }
// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
/** @var \OC\Files\Storage\Storage $partStorage */
@@ -257,6 +263,8 @@ class File extends Node implements IFile {
throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
} catch (StorageNotAvailableException $e) {
throw new ServiceUnavailable("Failed to open file: " . $e->getMessage());
+ } catch (LockedException $e) {
+ throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
}
@@ -278,6 +286,8 @@ class File extends Node implements IFile {
}
} catch (StorageNotAvailableException $e) {
throw new ServiceUnavailable("Failed to unlink: " . $e->getMessage());
+ } catch (LockedException $e) {
+ throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
}
@@ -383,6 +393,8 @@ class File extends Node implements IFile {
return $info->getEtag();
} catch (StorageNotAvailableException $e) {
throw new ServiceUnavailable("Failed to put file: " . $e->getMessage());
+ } catch (LockedException $e) {
+ throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
}