From fd4efdded9d0dfbccfbeb15dfe40022e07174f3c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 1 Jul 2015 09:30:18 +0200 Subject: [PATCH 1/2] Clean up part file only once, not twice on error --- lib/private/connector/sabre/file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 93244bea6ff..c28ac584998 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -189,7 +189,6 @@ class File extends Node implements IFile { } if (!$run || $renameOkay === false || $fileExists === false) { \OC_Log::write('webdav', 'renaming part file to final file failed', \OC_Log::ERROR); - $partStorage->unlink($internalPartPath); throw new Exception('Could not rename part file to final file'); } } catch (\Exception $e) { @@ -350,6 +349,7 @@ class File extends Node implements IFile { if ($chunk_handler->isComplete()) { list($storage,) = $this->fileView->resolvePath($path); $needsPartFile = $this->needsPartFile($storage); + $partFile = null; try { $targetPath = $path . '/' . $info['name']; @@ -388,7 +388,7 @@ class File extends Node implements IFile { $info = $this->fileView->getFileInfo($targetPath); return $info->getEtag(); } catch (\Exception $e) { - if ($partFile) { + if ($partFile !== null) { $this->fileView->unlink($partFile); } $this->convertToSabreException($e); From cf245b80fe8bf0aed2b227e7f2cef5a15d3c5c8b Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 1 Jul 2015 12:52:06 +0200 Subject: [PATCH 2/2] Only delete part file on error if it is really a part file --- lib/private/connector/sabre/file.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index c28ac584998..e4f53a219d2 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -146,7 +146,9 @@ class File extends Node implements IFile { } } catch (\Exception $e) { - $partStorage->unlink($internalPartPath); + if ($needsPartFile) { + $partStorage->unlink($internalPartPath); + } $this->convertToSabreException($e); } @@ -176,7 +178,9 @@ class File extends Node implements IFile { try { $this->fileView->changeLock($this->path, ILockingProvider::LOCK_EXCLUSIVE); } catch (LockedException $e) { - $partStorage->unlink($internalPartPath); + if ($needsPartFile) { + $partStorage->unlink($internalPartPath); + } throw new FileLocked($e->getMessage(), $e->getCode(), $e); }