diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index a24af3b9d3..2312b9b8b6 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -675,7 +675,10 @@ public function putFile(string $fileId, string $access_token): JSONResponse { $this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content)); } catch (LockedException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR); + // The file is locked by another operation and we wrote nothing. + // Report it as such, so the client can retry rather than treat + // this as a server fault or as a change behind its back. + return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED); } if ($isPutRelative) { @@ -819,7 +822,8 @@ public function postFile(string $fileId, string $access_token): JSONResponse { try { $this->wrappedFilesystemOperation($wopi, fn () => $file->putContent($content)); } catch (LockedException) { - return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR); + // As in putFile(): nothing was written, so this is not a server fault. + return new JSONResponse(['message' => 'File locked'], Http::STATUS_LOCKED); } // epub is exception (can be uploaded but not opened so don't try to get access token)