From 0d9ad1416571b1e73f590b784dbd7320e75bb0cb Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 2 Jul 2015 10:47:54 +0200 Subject: Properly handle NotPermittedException in SabreDAV --- lib/private/connector/sabre/file.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index e57d04f9a6e..0831bb374d5 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -142,6 +142,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\ throw new \Sabre\DAV\Exception('Could not rename part file to final file'); } } + catch (\OCP\Files\NotPermittedException $e) { + // a more general case - due to whatever reason the content could not be written + throw new \Sabre\DAV\Exception\Forbidden($e->getMessage(), $e->getCode(), $e); + } catch (\OCP\Files\LockNotAcquiredException $e) { // the file is currently being written to by another process throw new OC_Connector_Sabre_Exception_FileLocked($e->getMessage(), $e->getCode(), $e); -- cgit v1.2.3 From c9e77c7de49400234f730147f7cf2b4de140bc2b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 2 Jul 2015 11:01:01 +0200 Subject: Remove unneeded part file --- lib/private/connector/sabre/file.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 0831bb374d5..f29e3620d4a 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -143,6 +143,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\ } } catch (\OCP\Files\NotPermittedException $e) { + $this->fileView->unlink($partFilePath); // a more general case - due to whatever reason the content could not be written throw new \Sabre\DAV\Exception\Forbidden($e->getMessage(), $e->getCode(), $e); } @@ -332,6 +333,12 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\ $info = $this->fileView->getFileInfo($targetPath); return $info->getEtag(); + } catch (\OCP\Files\NotPermittedException $e) { + if ($needsPartFile) { + $this->fileView->unlink($partFile); + } + // a more general case - due to whatever reason the content could not be written + throw new \Sabre\DAV\Exception\Forbidden($e->getMessage(), $e->getCode(), $e); } catch (\OCP\Files\StorageNotAvailableException $e) { throw new \Sabre\DAV\Exception\ServiceUnavailable("Failed to put file: ".$e->getMessage()); } -- cgit v1.2.3