Skip to content

Conversation

@miaulalala
Copy link
Contributor

@miaulalala miaulalala commented Dec 12, 2024

Signed-off-by: Anna Larch anna@nextcloud.com

  • Resolves: #

Summary

TODO

  • ...

Checklist

@miaulalala miaulalala self-assigned this Dec 12, 2024
@miaulalala miaulalala added the 2. developing Work in progress label Dec 12, 2024
@miaulalala
Copy link
Contributor Author

/backport to stable28

@miaulalala miaulalala marked this pull request as ready for review December 16, 2024 15:29
Signed-off-by: Anna Larch <anna@nextcloud.com>
@miaulalala miaulalala force-pushed the fix/noid/empty-path-for-files-versions branch from 2ebc7dd to a39a5c6 Compare December 17, 2024 13:54
@solracsf
Copy link
Member

solracsf commented Dec 18, 2024

DRY 🙈

/**
 * Retrieve the path relative to the current user root folder.
 * If no user is connected, try to use the node's owner.
 */
private function getPathForNode(Node $node): ?string {
	$user = $this->userSession->getUser()?->getUID();
	if ($user !== null) {
		return $this->getRelativePathForUser($user, $node);
	}

	$owner = $node->getOwner()?->getUid();
	if ($owner !== null) {
		return $this->getRelativePathForUser($owner, $node);
	}

	// Attempt to extract the owner from the path
	$parts = explode('/', $node->getPath(), 4);
	$owner = (count($parts) === 4) ? $parts[1] : null;
	if ($owner !== null) {
		return $this->getRelativePathForUser($owner, $node);
	}

	return null;
}

/**
 * Get the relative path for a given user and node.
 */
private function getRelativePathForUser(string $user, Node $node): ?string {
	return $this->rootFolder
		->getUserFolder($user)
		->getRelativePath($node->getPath()) ?: null;
}

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Not sure what the difference is with the original

@SystemKeeper
Copy link
Contributor

Not sure what the difference is with the original

In the original version we only try to extract the owner from the path, when we are unable to get the owner from the node.

Now we try to get the owner from the path as a fallback in all cases.

@susnux susnux added this to the Nextcloud 29.0.14 milestone Mar 2, 2025
@Altahrim Altahrim mentioned this pull request Mar 18, 2025
28 tasks
@blizzz blizzz mentioned this pull request Mar 19, 2025
This was referenced Apr 3, 2025
@miaulalala miaulalala requested a review from artonge April 8, 2025 11:53
@skjnldsv skjnldsv mentioned this pull request Apr 10, 2025
15 tasks
@skjnldsv
Copy link
Member

29 is now EOL

@skjnldsv skjnldsv closed this Apr 11, 2025
@github-project-automation github-project-automation bot moved this from 🏗️ In progress to ☑️ Done in 💬 Talk team Apr 11, 2025
@susnux susnux deleted the fix/noid/empty-path-for-files-versions branch April 23, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

8 participants