Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need the string cast anymore since I added a name in the ApiServiceTest.php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you should also be able to remove /** @psalm-suppress RedundantCastGivenDocblockType */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @rikled! Then it will look like:

if (!$readOnly) { 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it should look like this:

		// Disable file locking for Readme.md files, because in the
		// current setup, this makes it almost impossible to delete these files.
		if (!$readOnly && strcasecmp($file->getName(), 'Readme.md') !== 0) {

so just remove the string cast and the psalm suppress command. Then hopefully the php unit tests will still pass.

$isLocked = $this->documentService->lock($file->getId());
if (!$isLocked) {
$readOnly = true;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Service/ApiServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading