Merge pull request #9392 from nextcloud/dav-upload-lock-13
[13] only allow a single concurrent dav write to a file
This commit is contained in:
commit
56b8a889c1
|
@ -28,6 +28,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OCA\DAV\Connector\Sabre;
|
namespace OCA\DAV\Connector\Sabre;
|
||||||
|
|
||||||
use OC\Files\View;
|
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);
|
$info = new \OC\Files\FileInfo($path, null, null, [], null);
|
||||||
}
|
}
|
||||||
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
|
$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);
|
$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) {
|
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
||||||
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), $e->getCode(), $e);
|
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage(), $e->getCode(), $e);
|
||||||
} catch (InvalidPathException $ex) {
|
} catch (InvalidPathException $ex) {
|
||||||
|
|
Loading…
Reference in New Issue