diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-05-03 16:28:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-03 16:28:39 +0200 |
commit | 7cb467b4767e2bc0338e75172d0c855b67f263dc (patch) | |
tree | 5a47ce970678b2124afbfc298d4646774969da26 /apps | |
parent | ceb674632c4551da29c53918776153cfa36cf6ad (diff) | |
parent | dd1b0799a422bfb2dfe167942953af08c007ba4f (diff) | |
download | nextcloud-server-7cb467b4767e2bc0338e75172d0c855b67f263dc.tar.gz nextcloud-server-7cb467b4767e2bc0338e75172d0c855b67f263dc.zip |
Merge pull request #9355 from nextcloud/dav-upload-lock
only allow a single concurrent dav write to a file
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Directory.php | 11 |
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) { |