Skip to content

Commit a42ca93

Browse files
authored
Merge pull request #6063 from nextcloud/backport/6054/stable34
[stable34] fix(wopi): report a locked file as 423, not 500
2 parents c4dba9f + d6e4c6f commit a42ca93

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
@@ -665,7 +665,10 @@ public function putFile(
665665
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
666666
} catch (LockedException $e) {
667667
$this->logger->error($e->getMessage(), ['exception' => $e]);
668-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
668+
// The file is locked by another operation and we wrote nothing.
669+
// Report it as such, so the client can retry rather than treat
670+
// this as a server fault or as a change behind its back.
671+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
669672
}
670673

671674
if ($wopi->hasTemplateId()) {
@@ -808,7 +811,8 @@ public function postFile(
808811
try {
809812
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
810813
} catch (LockedException) {
811-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
814+
// As in putFile(): nothing was written, so this is not a server fault.
815+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
812816
}
813817

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

0 commit comments

Comments
 (0)