Skip to content
Open
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 @@ -129,7 +129,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) {
Comment on lines +134 to +135
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** @psalm-suppress RedundantCastGivenDocblockType */
if (!$readOnly && strcasecmp((string)$file->getName(), 'Readme.md') !== 0) {
if (!$readOnly && strcasecmp($file->getName(), 'Readme.md') !== 0) {

I think if the phpunit tests fail on that it is rather due to the file mock not having calls of getName mocked.

Probably just a matter of addding in

$file->method('getId')->willReturn($id);

$file->method('getName')->willReturn('MyFile.md');

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

So, shall I fix the tests then?

$isLocked = $this->documentService->lock($file->getId());
if (!$isLocked) {
$readOnly = true;
Expand Down
Loading