Skip to content
Closed
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
29 changes: 18 additions & 11 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,7 @@ private function getPathForNode(Node $node): ?string {

$owner = $node->getOwner()?->getUid();

// If no owner, extract it from the path.
// e.g. /user/files/foobar.txt
if (!$owner) {
$parts = explode('/', $node->getPath(), 4);
if (count($parts) === 4) {
$owner = $parts[1];
}
}

if ($owner) {
if ($owner !== null) {
$path = $this->rootFolder
->getUserFolder($owner)
->getRelativePath($node->getPath());
Expand All @@ -403,6 +394,22 @@ private function getPathForNode(Node $node): ?string {
}
}

return null;
// If no owner, or didn't find a path for the owner,
// extract the owner name from the path and try again
// Happens when a file version is owned by a different user than the owner of
// the original file
// @see https://github.com/nextcloud/server/issues/40090
$parts = explode('/', $node->getPath(), 4);
if (count($parts) === 4) {
$owner = $parts[1];
}

if ($owner === '' || $owner === null) {
return null;
}

return $this->rootFolder
->getUserFolder($owner)
->getRelativePath($node->getPath());
}
}
Loading