diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-07-01 15:20:53 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-07-01 15:20:53 +0200 |
commit | 709eca20854c60a41ac811854174a6e883b8f770 (patch) | |
tree | 86a65844abe321c87f6ac98d870eca4b8aad8ae7 /lib | |
parent | fb2ec1dc560b1ee77cf88878315ecdef4671902f (diff) | |
parent | cf245b80fe8bf0aed2b227e7f2cef5a15d3c5c8b (diff) | |
download | nextcloud-server-709eca20854c60a41ac811854174a6e883b8f770.tar.gz nextcloud-server-709eca20854c60a41ac811854174a6e883b8f770.zip |
Merge pull request #17268 from owncloud/files-cleanuppartfileonlyonce
Clean up part file only once, not twice on error
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/connector/sabre/file.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 93244bea6ff..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); } @@ -189,7 +193,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 +353,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 +392,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); |