locking for chunked dav upload

This commit is contained in:
Robin Appelman 2015-06-23 13:52:27 +02:00
parent 1a84c8e9d2
commit 23eaf27a5b
1 changed files with 7 additions and 4 deletions

View File

@ -379,12 +379,13 @@ class File extends Node implements IFile {
$this->emitPreHooks($exists, $targetPath);
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
/** @var \OC\Files\Storage\Storage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath);
if ($needsPartFile) {
// we first assembly the target file as a part file
$partFile = $path . '/' . $info['name'] . '.ocTransferId' . $info['transferid'] . '.part';
/** @var \OC\Files\Storage\Storage $targetStorage */
list($partStorage, $partInternalPath) = $this->fileView->resolvePath($partFile);
@ -392,8 +393,7 @@ class File extends Node implements IFile {
// here is the final atomic rename
$renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath);
$fileExists = $this->fileView->file_exists($targetPath);
$fileExists = $targetStorage->file_exists($targetInternalPath);
if ($renameOkay === false || $fileExists === false) {
\OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::rename() failed', \OCP\Util::ERROR);
// only delete if an error occurred and the target file was already created
@ -427,6 +427,9 @@ class File extends Node implements IFile {
$this->emitPostHooks($exists, $targetPath);
$info = $this->fileView->getFileInfo($targetPath);
$this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED);
return $info->getEtag();
} catch (\Exception $e) {
if ($partFile !== null) {