[Pkg-owncloud-commits] [owncloud] 63/66: Backported sabre exception logger

David Prévot taffit at moszumanska.debian.org
Fri Apr 18 22:49:49 UTC 2014


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

taffit pushed a commit to annotated tag v5.0.15
in repository owncloud.

commit cb7369659fc636feb71baea29c7f355daaacd390
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Feb 27 16:44:25 2014 +0100

    Backported sabre exception logger
    
    Partial backport of 11ef12a
    
    Whenever an exception occurs in the sabre connector code or code called
    by it, it will be logged.
    
    This plugin approach is needed because Sabre already catches exceptions
    to return them to the client in the XML response, so they don't appear
    logged in the web server log.
    
    This will make it much easier to debug syncing issues.
---
 apps/files/appinfo/remote.php                 |  1 +
 lib/connector/sabre/exceptionloggerplugin.php | 50 +++++++++++++++++++++++++++
 lib/connector/sabre/file.php                  |  2 +-
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php
index a144414..4cecaf2 100644
--- a/apps/files/appinfo/remote.php
+++ b/apps/files/appinfo/remote.php
@@ -49,6 +49,7 @@ $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend));
 $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload
 $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin());
 $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
+$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));
 
 // And off we go!
 $server->exec();
diff --git a/lib/connector/sabre/exceptionloggerplugin.php b/lib/connector/sabre/exceptionloggerplugin.php
new file mode 100644
index 0000000..8e77afa
--- /dev/null
+++ b/lib/connector/sabre/exceptionloggerplugin.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @author Vincent Petry
+ * @copyright 2014 Vincent Petry <pvince81 at owncloud.com>
+ *
+ * @license AGPL3
+ */
+
+class OC_Connector_Sabre_ExceptionLoggerPlugin extends Sabre_DAV_ServerPlugin
+{
+	private $appName;
+
+	/**
+	 * @param string $loggerAppName app name to use when logging
+	 */
+	public function __construct($loggerAppName = 'webdav') {
+		$this->appName = $loggerAppName;
+	}
+
+	/**
+	 * This initializes the plugin.
+	 *
+	 * This function is called by Sabre_DAV_Server, after
+	 * addPlugin is called.
+	 *
+	 * This method should set up the required event subscriptions.
+	 *
+	 * @param Sabre_DAV_Server $server
+	 * @return void
+	 */
+	public function initialize(Sabre_DAV_Server $server) {
+
+		$server->subscribeEvent('exception', array($this, 'logException'), 10);
+	}
+
+	/**
+	 * Log exception
+	 *
+	 * @internal param Exception $e exception
+	 */
+	public function logException($e) {
+		$exceptionClass = get_class($e);
+		if ($exceptionClass !== 'Sabre_DAV_Exception_NotAuthenticated') {
+			\OCP\Util::logException($this->appName, $e);
+		}
+	}
+}
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index bbfb27a..d3974be 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -81,7 +81,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
 		if ($renameOkay === false || $fileExists === false) {
 			\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
 			\OC\Files\Filesystem::unlink($partpath);
-			throw new Sabre_DAV_Exception();
+			throw new Sabre_DAV_Exception('Could not rename part file to final file');
 		}
 
 

-- 
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