Skip to content
Merged
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
6 changes: 5 additions & 1 deletion apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ private function getPathForNode(Node $node): ?string {
}
}

$owner = $node->getOwner()?->getUid();
try {
$owner = $node->getOwner()?->getUid();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not a deeper problem @come-nc ?
So this method is not marked as throwing, but just to return null if not found.
Meaning should we fix the getOwner method or at least add the throwing to the docs?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is how we manage non-existing files, see https://github.com/nextcloud/server/blob/master/lib/private/Files/Node/NonExistingFile.php

We could mark all methods as throwing but that would trigger a lot of false positive.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually for getOwner the throw comes from Node::getFileInfo directly I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

But in this case the file exists

Copy link
Contributor

Choose a reason for hiding this comment

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

No it does not.
Look at the trace in nextcloud/forms#2435
It’s triggered by rename hook, so either source or target does not exist, depending if we are in the pre- or post- rename hook/event.

} catch (\OCP\Files\NotFoundException) {
$owner = null;
}

// If no owner, extract it from the path.
// e.g. /user/files/foobar.txt
Expand Down
Loading