Skip to content

Commit e961a00

Browse files
authored
Merge pull request #6061 from nextcloud/backport/6054/stable32
[stable32] fix(wopi): report a locked file as 423, not 500
2 parents e36a132 + 9d3f4d7 commit e961a00

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/Controller/WopiController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,10 @@ public function putFile(string $fileId, string $access_token): JSONResponse {
675675
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
676676
} catch (LockedException $e) {
677677
$this->logger->error($e->getMessage(), ['exception' => $e]);
678-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
678+
// The file is locked by another operation and we wrote nothing.
679+
// Report it as such, so the client can retry rather than treat
680+
// this as a server fault or as a change behind its back.
681+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
679682
}
680683

681684
if ($isPutRelative) {
@@ -819,7 +822,8 @@ public function postFile(string $fileId, string $access_token): JSONResponse {
819822
try {
820823
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
821824
} catch (LockedException) {
822-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
825+
// As in putFile(): nothing was written, so this is not a server fault.
826+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
823827
}
824828

825829
// epub is exception (can be uploaded but not opened so don't try to get access token)

0 commit comments

Comments
 (0)