Skip to content

Commit

Permalink
Merge pull request #442 from nextcloud/bugfix/428
Browse files Browse the repository at this point in the history
fix: Return X-WOPI-Lock when a manual lock from outside exists
  • Loading branch information
blizzz authored May 16, 2023
2 parents 4d355b9 + ebd3f14 commit 55a346c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private function getLock(Wopi $wopi): JSONResponse {
try {
$response = new JSONResponse();
$locks = $this->lockManager->getLocks($wopi->getFileid());
$existingLock = array_pop($locks);
$existingLock = array_shift($locks);
$response->addHeader('X-WOPI-Lock', $existingLock->getToken());
return $response;
} catch (NoLockProviderException|PreConditionNotMetException $e) {
Expand Down Expand Up @@ -671,6 +671,16 @@ public function postFile($fileId, $access_token) {
$wopiOverride = $this->request->getHeader('X-WOPI-Override');

if ($this->lockManager->isLockProviderAvailable()) {
$locks = $this->lockManager->getLocks($wopi->getFileid());
$existingLock = array_shift($locks);
$outsideLocked = $existingLock && $existingLock->getOwner() !== 'officeonline';
if ($outsideLocked) {
$result = new JSONResponse();
$result->setStatus(Http::STATUS_CONFLICT);
$result->addHeader('X-WOPI-Lock', $existingLock->getToken());
$result->addHeader('X-WOPI-LockFailureReason', 'File already locked by ' . $existingLock->getOwner());
return $result;
}
// Currently we do not use the return value of those methods,
// as we perform actual WOPI lock token handling through the apps own lock table
switch ($wopiOverride) {
Expand Down

0 comments on commit 55a346c

Please sign in to comment.