Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getOwner to FileInfo #20224

Merged
merged 2 commits into from
Nov 10, 2015
Merged

Add getOwner to FileInfo #20224

merged 2 commits into from
Nov 10, 2015

Conversation

icewind1991
Copy link
Contributor

Expose file owner in fileinfo

  • Add Tests

@@ -1248,7 +1248,8 @@ public function getFileInfo($path, $includeMountPoints = true) {
$data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
}

return new FileInfo($path, $storage, $internalPath, $data, $mount);
$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit worried that it will become expensive to resolve all users. Imagine a folder where each subfolder is a shared mount. I'd rather we still keep it as the user id and let the API consumer decide whether to retrieve the user object for it or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I do agree that in an object-oriented view it makes sense, but we don't want additional performance impact, especially considering that the user manager might be LDAP)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we already resolve all users anyway and the usermanager will cache them

Copy link
Contributor

Choose a reason for hiding this comment

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

@blizzz can you confirm this belief ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not so much into this part of the code, so I dived a bit into it. As LDAP user I shared a file to a local one, and logged in with the local on, while having a debug session. What I already find surprising is that while $mount is a Shared_Mount the storage it returns is a Files_Trashbin/Storage. Should it be like this? The $internalPath will be empty, $data however is set correctly and the owner is correct as well.

Anyway, the LDAP owner is already cached at this point of time.

Copy link
Contributor

Choose a reason for hiding this comment

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

@blizzz what you observed is the storage wrappers. Basically Wrapper A wraps Wrapper B wraps Wrapper C wraps Storage, where each wrapper can be "trashbin wrapper", "encryption wrapper", etc.

The part I'd like to double check is whether the user object gets resolved for every new user that is queried.
Basically if I call getUserManager()->get('user1') then same with user2, then user3, then user4, whether it will make 4 different queries or whether these 4 users were already cached somewhere.

Also the second part to check: if I am receiving 4 shares from each of these users respectively, whether these users have already been pre-resolved through SharedStorage. If they have, then calling getUserManager()->get() should be fine. However if the users are not pre-resolved, then this will cause an additional needless performance impact: because not everyone might need the $owner from FileInfo, so we should always resolve it.

@icewind1991 can you help clarifying this or do you want me to dive into the code to check it ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@icewind1991 show me a blackfire diff before/after this PR 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PVince81 we resolve the user object for every share owner (at least) here already

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I'm convinced 😄

@icewind1991
Copy link
Contributor Author

Added tests and set default value to null

@PVince81
Copy link
Contributor

👍

@icewind1991
Copy link
Contributor Author

@MorrisJobke @rullzer please review

@rullzer
Copy link
Contributor

rullzer commented Nov 10, 2015

👍

icewind1991 added a commit that referenced this pull request Nov 10, 2015
@icewind1991 icewind1991 merged commit bbe2f5c into master Nov 10, 2015
@icewind1991 icewind1991 deleted the fileinfo-owner branch November 10, 2015 13:36
@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants