Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid unlocking too early and fix collaboration in Word #423

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,14 @@ private function lock(Wopi $wopi): JSONResponse {
private function unlock(Wopi $wopi): JSONResponse {
try {
$wopiLock = $this->request->getHeader('X-WOPI-Lock');

// OOS sends UNLOCK with GetCurrentLock-00000000-0000-0000-0000-000000000000
// instead of GET_LOCK it seems, so we cannot always unlock
$fLock = $this->lockMapper->find($wopi->getFileid());
if ($fLock->getValue() !== $wopiLock) {
return new JSONResponse();
}

$this->lockManager->unlock(new LockContext(
$this->getFileForWopiToken($wopi),
ILock::TYPE_APP,
Expand Down Expand Up @@ -661,27 +669,36 @@ public function postFile($fileId, $access_token) {
}

$wopiOverride = $this->request->getHeader('X-WOPI-Override');

if ($this->lockManager->isLockProviderAvailable()) {
// 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) {
case 'LOCK':
return $this->lock($wopi);
case 'UNLOCK':
return $this->unlock($wopi);
case 'REFRESH_LOCK':
return $this->refreshLock($wopi);
case 'GET_LOCK':
return $this->getLock($wopi);
}
} else {
switch ($wopiOverride) {
case 'LOCK':
$this->lock($wopi);
break;
case 'UNLOCK':
$this->unlock($wopi);
break;
case 'REFRESH_LOCK':
$this->refreshLock($wopi);
break;
case 'GET_LOCK':
return $this->fallbackLock($fileId, $access_token);
$this->getLock($wopi);
break;
}
}

// FIXME: We should merge the fallbackLock method into the above individual methods
// The specific table is still relevant to cover different lock tokens used by OOS
switch ($wopiOverride) {
case 'LOCK':
case 'UNLOCK':
case 'REFRESH_LOCK':
case 'GET_LOCK':
return $this->fallbackLock($fileId, $access_token);
}

$isRenameFile = ($wopiOverride === 'RENAME_FILE');

// Unless the editor is empty (public link) we modify the files as the current editor
Expand Down