summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-05-23 20:14:19 +0200
committerGitHub <noreply@github.com>2018-05-23 20:14:19 +0200
commit56b8a889c16b1d57dc2fec9e36a86659b1f31e0d (patch)
tree65cb472da38202fe8878e52c1cdbad8446cda188 /apps/dav
parent2f059d1caf006253ccfa9334702f86469cc3a3c8 (diff)
parent187acecff77ebccb5dbfa5b77081252007b0cbf9 (diff)
downloadnextcloud-server-56b8a889c16b1d57dc2fec9e36a86659b1f31e0d.tar.gz
nextcloud-server-56b8a889c16b1d57dc2fec9e36a86659b1f31e0d.zip
Merge pull request #9392 from nextcloud/dav-upload-lock-13
[13] only allow a single concurrent dav write to a file
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index a7b8ea1755e..aaf5f54ec26 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -28,6 +28,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OCA\DAV\Connector\Sabre;
use OC\Files\View;
@@ -147,8 +148,16 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
$info = new \OC\Files\FileInfo($path, null, null, [], null);
}
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
+
+ // only allow 1 process to upload a file at once but still allow reading the file while writing the part file
$node->acquireLock(ILockingProvider::LOCK_SHARED);
- return $node->put($data);
+ $this->fileView->lockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
+
+ $result = $node->put($data);
+
+ $this->fileView->unlockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
+ $node->releaseLock(ILockingProvider::LOCK_SHARED);
+ return $result;
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), $e->getCode(), $e);
} catch (InvalidPathException $ex) {