Skip to content
Snippets Groups Projects
Commit 709eca20 authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #17268 from owncloud/files-cleanuppartfileonlyonce

Clean up part file only once, not twice on error
parents fb2ec1dc cf245b80
Branches
No related tags found
No related merge requests found
...@@ -146,7 +146,9 @@ class File extends Node implements IFile { ...@@ -146,7 +146,9 @@ class File extends Node implements IFile {
} }
} catch (\Exception $e) { } catch (\Exception $e) {
if ($needsPartFile) {
$partStorage->unlink($internalPartPath); $partStorage->unlink($internalPartPath);
}
$this->convertToSabreException($e); $this->convertToSabreException($e);
} }
...@@ -176,7 +178,9 @@ class File extends Node implements IFile { ...@@ -176,7 +178,9 @@ class File extends Node implements IFile {
try { try {
$this->fileView->changeLock($this->path, ILockingProvider::LOCK_EXCLUSIVE); $this->fileView->changeLock($this->path, ILockingProvider::LOCK_EXCLUSIVE);
} catch (LockedException $e) { } catch (LockedException $e) {
if ($needsPartFile) {
$partStorage->unlink($internalPartPath); $partStorage->unlink($internalPartPath);
}
throw new FileLocked($e->getMessage(), $e->getCode(), $e); throw new FileLocked($e->getMessage(), $e->getCode(), $e);
} }
...@@ -189,7 +193,6 @@ class File extends Node implements IFile { ...@@ -189,7 +193,6 @@ class File extends Node implements IFile {
} }
if (!$run || $renameOkay === false || $fileExists === false) { if (!$run || $renameOkay === false || $fileExists === false) {
\OC_Log::write('webdav', 'renaming part file to final file failed', \OC_Log::ERROR); \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'); throw new Exception('Could not rename part file to final file');
} }
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -350,6 +353,7 @@ class File extends Node implements IFile { ...@@ -350,6 +353,7 @@ class File extends Node implements IFile {
if ($chunk_handler->isComplete()) { if ($chunk_handler->isComplete()) {
list($storage,) = $this->fileView->resolvePath($path); list($storage,) = $this->fileView->resolvePath($path);
$needsPartFile = $this->needsPartFile($storage); $needsPartFile = $this->needsPartFile($storage);
$partFile = null;
try { try {
$targetPath = $path . '/' . $info['name']; $targetPath = $path . '/' . $info['name'];
...@@ -388,7 +392,7 @@ class File extends Node implements IFile { ...@@ -388,7 +392,7 @@ class File extends Node implements IFile {
$info = $this->fileView->getFileInfo($targetPath); $info = $this->fileView->getFileInfo($targetPath);
return $info->getEtag(); return $info->getEtag();
} catch (\Exception $e) { } catch (\Exception $e) {
if ($partFile) { if ($partFile !== null) {
$this->fileView->unlink($partFile); $this->fileView->unlink($partFile);
} }
$this->convertToSabreException($e); $this->convertToSabreException($e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment