summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre
diff options
context:
space:
mode:
authorPellaeon Lin <nfsmwlin@gmail.com>2014-01-30 22:50:20 +0800
committerPellaeon Lin <nfsmwlin@gmail.com>2014-01-30 22:50:20 +0800
commit099b71c712c38de7dac7e386252da02bb0cadf12 (patch)
tree84bcf83efdc4cc759a5ff184fa5148195abaab51 /lib/private/connector/sabre
parent929c930b0afd682bb98eb389d7ebad91bb34d643 (diff)
parent299a8285bd2601ccbac988b2e3e9b067d47921a2 (diff)
downloadnextcloud-server-099b71c712c38de7dac7e386252da02bb0cadf12.tar.gz
nextcloud-server-099b71c712c38de7dac7e386252da02bb0cadf12.zip
Merge branch 'master' into pr-exceed_upload_limit_msg
Conflicts: apps/files/templates/index.php apps/files_sharing/templates/public.php
Diffstat (limited to 'lib/private/connector/sabre')
-rw-r--r--lib/private/connector/sabre/exceptionloggerplugin.php50
-rw-r--r--lib/private/connector/sabre/file.php13
2 files changed, 58 insertions, 5 deletions
diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php
new file mode 100644
index 00000000000..8e77afaf207
--- /dev/null
+++ b/lib/private/connector/sabre/exceptionloggerplugin.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * ownCloud
+ *
+ * @author Vincent Petry
+ * @copyright 2014 Vincent Petry <pvince81@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/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 295575f0af6..ed27cef440d 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -64,7 +64,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
// mark file as partial while uploading (ignored by the scanner)
- $partpath = $this->path . '.part';
+ $partpath = $this->path . '.ocTransferId' . rand() . '.part';
// if file is located in /Shared we write the part file to the users
// root folder because we can't create new files in /shared
@@ -79,7 +79,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
\OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR);
$fs->unlink($partpath);
// because we have no clue about the cause we can only throw back a 500/Internal Server Error
- throw new Sabre_DAV_Exception();
+ throw new Sabre_DAV_Exception('Could not write file contents');
}
} catch (\OCP\Files\NotPermittedException $e) {
// a more general case - due to whatever reason the content could not be written
@@ -105,7 +105,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);
$fs->unlink($partpath);
- throw new Sabre_DAV_Exception();
+ throw new Sabre_DAV_Exception('Could not rename part file to final file');
}
// allow sync clients to send the mtime along in a header
@@ -242,8 +242,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
$fileExists = $fs->file_exists($targetPath);
if ($renameOkay === false || $fileExists === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
- $fs->unlink($targetPath);
- throw new Sabre_DAV_Exception();
+ // only delete if an error occurred and the target file was already created
+ if ($fileExists) {
+ $fs->unlink($targetPath);
+ }
+ throw new Sabre_DAV_Exception('Could not rename part file assembled from chunks');
}
// allow sync clients to send the mtime along in a header