diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index 93a546ed529..45e754c2b5c 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -143,7 +143,10 @@ public function create(?int $fileId = null, ?string $filePath = null, ?string $b $hasOwner = $file->getOwner() !== null; - if (!$readOnly) { + // Disable file locking for Readme.md files, because in the + // current setup, this makes it almost impossible to delete these files. + /** @psalm-suppress RedundantCastGivenDocblockType */ + if (!$readOnly && strcasecmp((string)$file->getName(), 'Readme.md') !== 0) { $isLocked = $this->documentService->lock($file->getId()); if (!$isLocked) { $readOnly = true; diff --git a/tests/unit/Service/ApiServiceTest.php b/tests/unit/Service/ApiServiceTest.php index 83a4b848c84..f9b9cb4ddb2 100644 --- a/tests/unit/Service/ApiServiceTest.php +++ b/tests/unit/Service/ApiServiceTest.php @@ -72,6 +72,7 @@ private function mockFile(int $id, ?string $owner) { $file->method('getStorage')->willReturn($storage); $file->method('getId')->willReturn($id); $file->method('getOwner')->willReturn($owner); + $file->method('getName')->willReturn('name'); return $file; }