diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-09-15 17:59:44 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-10-20 14:14:56 +0200 |
commit | ddc8749814a38b33881721a8f4eccfe15e13dacb (patch) | |
tree | 2f04b9e991ea8f820e2644dff96d3f096fd092e6 | |
parent | 21d02673becc2bc9f7312eae18c3150778a94364 (diff) | |
download | nextcloud-server-ddc8749814a38b33881721a8f4eccfe15e13dacb.tar.gz nextcloud-server-ddc8749814a38b33881721a8f4eccfe15e13dacb.zip |
Adjust for wide locking
-rw-r--r-- | apps/dav/lib/connector/sabre/file.php | 14 | ||||
-rw-r--r-- | apps/dav/lib/connector/sabre/lockplugin.php | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php index a0581de53ae..df9d98b9792 100644 --- a/apps/dav/lib/connector/sabre/file.php +++ b/apps/dav/lib/connector/sabre/file.php @@ -349,9 +349,14 @@ class File extends Node implements IFile { if (empty($info)) { throw new NotImplemented('Invalid chunk name'); } + + $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); + $chunk_handler = new \OC_FileChunking($info); $bytesWritten = $chunk_handler->store($info['index'], $data); + $this->changeLock(ILockingProvider::LOCK_SHARED); + //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { if (isset($_SERVER['CONTENT_LENGTH'])) { @@ -376,9 +381,10 @@ class File extends Node implements IFile { $exists = $this->fileView->file_exists($targetPath); try { - $this->emitPreHooks($exists, $targetPath); + $this->fileView->lockFile($targetPath, ILockingProvider::LOCK_SHARED); - $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); + $this->emitPreHooks($exists, $targetPath); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_EXCLUSIVE); /** @var \OC\Files\Storage\Storage $targetStorage */ list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath); @@ -403,7 +409,7 @@ class File extends Node implements IFile { $partFile = null; $targetStorage->unlink($targetInternalPath); } - $this->changeLock(ILockingProvider::LOCK_SHARED); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED); throw new Exception('Could not rename part file assembled from chunks'); } } else { @@ -419,7 +425,7 @@ class File extends Node implements IFile { } } - $this->changeLock(ILockingProvider::LOCK_SHARED); + $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED); // since we skipped the view we need to scan and emit the hooks ourselves $this->fileView->getUpdater()->update($targetPath); diff --git a/apps/dav/lib/connector/sabre/lockplugin.php b/apps/dav/lib/connector/sabre/lockplugin.php index c564e066f8e..5840e59854c 100644 --- a/apps/dav/lib/connector/sabre/lockplugin.php +++ b/apps/dav/lib/connector/sabre/lockplugin.php @@ -62,7 +62,7 @@ class LockPlugin extends ServerPlugin { public function getLock(RequestInterface $request) { // we cant listen on 'beforeMethod:PUT' due to order of operations with setting up the tree // so instead we limit ourselves to the PUT method manually - if ($request->getMethod() !== 'PUT') { + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { return; } try { @@ -80,7 +80,7 @@ class LockPlugin extends ServerPlugin { } public function releaseLock(RequestInterface $request) { - if ($request->getMethod() !== 'PUT') { + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { return; } try { |