[Pkg-owncloud-commits] [owncloud] 143/273: Add StorageNotAvailableException
David Prévot
taffit at moszumanska.debian.org
Fri Jul 4 03:13:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit d78a2a9f78dc2a65bffa8f3fc4299c4540c4d5be
Author: Robin Appelman <icewind at owncloud.com>
Date: Mon Jun 30 15:46:37 2014 +0200
Add StorageNotAvailableException
---
lib/private/files/storage/dav.php | 44 ++++++++++++++---------
lib/public/files/storagenotavailableexception.php | 19 ++++++++++
2 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index 8b97f75..726688f 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -8,6 +8,9 @@
namespace OC\Files\Storage;
+use OCP\Files\StorageNotAvailableException;
+use Sabre\DAV\Exception;
+
class DAV extends \OC\Files\Storage\Common {
protected $password;
protected $user;
@@ -463,29 +466,36 @@ class DAV extends \OC\Files\Storage\Common {
*
* @param string $path
* @param int $time
+ * @throws \OCP\Files\StorageNotAvailableException
* @return bool
*/
public function hasUpdated($path, $time) {
$this->init();
- $response = $this->client->propfind($this->encodePath($path), array(
- '{DAV:}getlastmodified',
- '{DAV:}getetag',
- '{http://owncloud.org/ns}permissions'
- ));
- if (isset($response['{DAV:}getetag'])) {
- $cachedData = $this->getCache()->get($path);
- $etag = trim($response['{DAV:}getetag'], '"');
- if ($cachedData['etag'] !== $etag) {
- return true;
- } else if (isset($response['{http://owncloud.org/ns}permissions'])) {
- $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
- return $permissions !== $cachedData['permissions'];
+ try {
+ $response = $this->client->propfind($this->encodePath($path), array(
+ '{DAV:}getlastmodified',
+ '{DAV:}getetag',
+ '{http://owncloud.org/ns}permissions'
+ ));
+ if (isset($response['{DAV:}getetag'])) {
+ $cachedData = $this->getCache()->get($path);
+ $etag = trim($response['{DAV:}getetag'], '"');
+ if ($cachedData['etag'] !== $etag) {
+ return true;
+ } else if (isset($response['{http://owncloud.org/ns}permissions'])) {
+ $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
+ return $permissions !== $cachedData['permissions'];
+ } else {
+ return false;
+ }
} else {
- return false;
+ $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
+ return $remoteMtime > $time;
}
- } else {
- $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
- return $remoteMtime > $time;
+ } catch (Exception\NotFound $e) {
+ return false;
+ } catch (Exception $e) {
+ throw new StorageNotAvailableException();
}
}
}
diff --git a/lib/public/files/storagenotavailableexception.php b/lib/public/files/storagenotavailableexception.php
new file mode 100644
index 0000000..fcc0c9c
--- /dev/null
+++ b/lib/public/files/storagenotavailableexception.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind at owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Files/AlreadyExistsException class
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP\Files;
+
+class StorageNotAvailableException extends \Exception {
+}
--
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