diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 77cb84e517..787244a352 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -663,7 +663,10 @@ public function putFile( $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 ($wopi->hasTemplateId()) { @@ -805,7 +808,8 @@ public function postFile( 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)