Skip to content

Commit a6647e4

Browse files
authored
Merge pull request #6064 from nextcloud/backport/6054/stable35
[stable35] fix(wopi): report a locked file as 423, not 500
2 parents 9a0d11c + 7ab42e1 commit a6647e4

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

669672
if ($wopi->hasTemplateId()) {
@@ -805,7 +808,8 @@ public function postFile(
805808
try {
806809
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
807810
} catch (LockedException) {
808-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
811+
// As in putFile(): nothing was written, so this is not a server fault.
812+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
809813
}
810814

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

0 commit comments

Comments
 (0)