Skip to content

Commit 25364b0

Browse files
authored
Merge pull request #6062 from nextcloud/backport/6054/stable33
[stable33] fix(wopi): report a locked file as 423, not 500
2 parents 6a8859c + 4d9ee9f commit 25364b0

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

707710
if ($isPutRelative) {
@@ -849,7 +852,8 @@ public function postFile(
849852
try {
850853
$this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content));
851854
} catch (LockedException) {
852-
return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);
855+
// As in putFile(): nothing was written, so this is not a server fault.
856+
return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED);
853857
}
854858

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

0 commit comments

Comments
 (0)