[Pkg-owncloud-commits] [owncloud] 228/457: Convert LockedException to FileLocked in Sabre connector

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:06:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit ba174ac626ae54b75565870fdeb55398436599e4
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri May 29 09:59:20 2015 +0200

    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
---
 lib/private/connector/sabre/file.php       | 14 +++++++++++++-
 lib/private/connector/sabre/objecttree.php |  8 ++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 325206f..3e1b29a 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);
 			}
 		}
 
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index 17d9aff..ed42a31 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -26,10 +26,12 @@
 namespace OC\Connector\Sabre;
 
 use OC\Connector\Sabre\Exception\InvalidPath;
+use OC\Connector\Sabre\Exception\FileLocked;
 use OC\Files\FileInfo;
 use OC\Files\Mount\MoveableMount;
 use OCP\Files\StorageInvalidException;
 use OCP\Files\StorageNotAvailableException;
+use OCP\Lock\LockedException;
 
 class ObjectTree extends \Sabre\DAV\Tree {
 
@@ -221,8 +223,10 @@ class ObjectTree extends \Sabre\DAV\Tree {
 			if (!$renameOkay) {
 				throw new \Sabre\DAV\Exception\Forbidden('');
 			}
-		} catch (\OCP\Files\StorageNotAvailableException $e) {
+		} catch (StorageNotAvailableException $e) {
 			throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
+		} catch (LockedException $e) {
+			throw new FileLocked($e->getMessage(), $e->getCode(), $e);
 		}
 
 		$this->markDirty($sourceDir);
@@ -258,7 +262,7 @@ class ObjectTree extends \Sabre\DAV\Tree {
 
 		try {
 			$this->fileView->copy($source, $destination);
-		} catch (\OCP\Files\StorageNotAvailableException $e) {
+		} catch (StorageNotAvailableException $e) {
 			throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
 		}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list