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

Store avatars outside of the home #26124

Merged
merged 10 commits into from
Oct 7, 2016
Merged

Store avatars outside of the home #26124

merged 10 commits into from
Oct 7, 2016

Conversation

PVince81
Copy link
Contributor

Resend of #25790 to master

Store avatars outside of the home

Inside a hidden "metadata-avatars" folder.
Doesn't require home FS setup

@DeepDiver1975 @butonic

@PVince81 PVince81 added this to the 9.2 milestone Sep 16, 2016
@mention-bot
Copy link

@PVince81, thanks for your PR! By analyzing the annotation information on this pull request, we identified @rullzer, @icewind1991 and @schiessle to be potential reviewers

@DeepDiver1975
Copy link
Member

$ ./occ  up
An unhandled exception has been thrown:
TypeError: Argument 3 passed to OC\Repair\MoveAvatarOutsideHome::__construct() must be an instance of OC\Repair\IUserManager, instance of OC\User\Manager given, called in /home/deepdiver/Development/ownCloud/master/lib/private/Repair.php on line 146 and defined in /home/deepdiver/Development/ownCloud/master/lib/private/Repair/MoveAvatarOutsideHome.php:51
Stack trace:
#0 /home/deepdiver/Development/ownCloud/master/lib/private/Repair.php(146): OC\Repair\MoveAvatarOutsideHome->__construct(Object(OC\AllConfig), Object(OC\DB\Connection), Object(OC\User\Manager))
#1 /home/deepdiver/Development/ownCloud/master/core/register_command.php(125): OC\Repair::getRepairSteps()
#2 /home/deepdiver/Development/ownCloud/master/lib/private/Console/Application.php(87): require_once('/home/deepdiver...')
#3 /home/deepdiver/Development/ownCloud/master/console.php(93): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/deepdiver/Development/ownCloud/master/occ(11): require_once('/home/deepdiver...')

@PVince81
Copy link
Contributor Author

Hmm, works for me when upgrading from stable9.1 to this branch.
Make sure you have the latest version of the branch.

@DeepDiver1975
Copy link
Member

DeepDiver1975 commented Sep 22, 2016

Loading time on the user page is roughly cut in half

bildschirmfoto von 2016-09-22 14-30-15
bildschirmfoto von 2016-09-22 14-29-48

@DeepDiver1975
Copy link
Member

tested - works 👍

@PVince81
Copy link
Contributor Author

We still need to decide whether the name of the folder "metadata-avatars" is acceptable or need something better.

@butonic
Copy link
Member

butonic commented Sep 22, 2016

since we want #18029 anyway I'd go with /path/to/data/_avatars. _avatars sorts nicely and if we add other global things whe should prefix them with _ as well.

@PVince81
Copy link
Contributor Author

how about "_metadata/avatars" ? This way there is only a single folder

@butonic
Copy link
Member

butonic commented Sep 22, 2016

@PVince81 I wrote down my thougts in #18029 (comment). I'd go for /path/to/data/users/a/d/admin/avatar.jpg. We need to move users anyway.

@PVince81
Copy link
Contributor Author

@butonic but in this case the avatar is back again in the user's home which we don't want.
You probably meant /path/to/data/avatars/a/d/admin/avatar.jpg ?

I don't want to introduce the "a/d" letters at this point, it seems too early. We don't even have a PR ready yet for the user migration which is a big topic.

@butonic
Copy link
Member

butonic commented Sep 22, 2016

We can do whatever we want for the avatar path, because it is not related to anything our virtual fs does. So '/path/to/data/users/a/d/admin/avatar.jpgshould work just fine, even if a user is calledusersbecause there are currently no other dirs interfering with the1/2/username` scheme.

Currently a file scan would pick up the avatars if a user users existed. But they wouldn't show up.

@butonic
Copy link
Member

butonic commented Sep 22, 2016

Id place the avatars there because I'd move the users files to /path/to/data/files/a/d/admin/. Then they no longer overlap

@PVince81
Copy link
Contributor Author

No it won't. /path/to/data/files/a/d/admin/ is still inside the user's home and requires setupFS to mount it, this is exactly what we want to avoid and is the reason why we wanted to move avatars outside the home to avoid setupFS when retrieving avatars. If metadata is outside too, then we can also avoid setupFS.

@DeepDiver1975
Copy link
Member

yes - we need to keep avatars out side the users home.

I don't care much how we name the avatars folder - move it out is the most important thing as of now.

@butonic
Copy link
Member

butonic commented Sep 22, 2016

what is the difference between
/path/to/data/files/a/d/admin/ and
/path/to/data/_avatars/a/d/admin/?

Neither is inside the users home? I'd just already put the users in subdirs to be future proof ...

@PVince81
Copy link
Contributor Author

As discussed yesterday I thought that /path/to/data/files/a/d/admin/ was the new/future home folder.
If this one is called "files", how would the future home folder be called then ?
I'd rather have it called "metadata" or "avatars" so an admin seeing this exact path can directly understand that it's about metadata, because when reading "files" one will believe it's about the user home's files.

@DeepDiver1975
Copy link
Member

Bringing back the user account table and the need to store various additional information with the user - what about storing the avatar in the vcard of the user account table - see #23558

@PVince81
Copy link
Contributor Author

PVince81 commented Sep 23, 2016

  • TODO: change target path to /path/to/data/avatars/a/d/admin/
  • in case the user id starts with { (LDAP id), use the md5 instead for cutting out the two letters


private function buildAvatarPath($userId) {
$prefix = $userId;
if (strlen($userId) < 2 || !ctype_alnum($userId[0]) || !ctype_alnum($userId[1])) {
Copy link
Member

Choose a reason for hiding this comment

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

KISS: just always md5 the uid ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: every time we use md5 we make it very difficult to reverse-lookup to an actual user (for example when an admin wants to find out to which user this folder belongs).
Remember the oc_storages problem with md5 entries.
I guess if it's only a md5 for the user id alone, then one might be able to generate a table of user ids to md5 to do a manual reverse lookup.

@@ -96,6 +96,9 @@ public function __construct(
$this->config = $config;

$this->excludedPaths[] = 'files_encryption';
$this->excludedPaths[] = 'metadata-avatars';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DeepDiver1975 @butonic we also need to adjust the path here else encryption is likely to cause trouble like it did on my first test

@PVince81
Copy link
Contributor Author

PVince81 commented Sep 27, 2016

  • BUG: adjust version of repair step
  • BUG: make repair step use the same new folder (might require to make getAvatarFolder public on a new interface IAvatarManager2 or make it a more generic utility method)
  • BUG?: weird md5 behavior: => was md5'ing the wrong thing
vincent@petry /srv/www/htdocs/owncloud/data/avatars/21/23/2f297a57a5a743894a0e4a801fc3
  % echo -n "2f297a57a5a743894a0e4a801fc3" | md5sum
56597a4557666304b6511a23e29ff93a  -

Not sure where 21 and 23 come from.
The logic with substr_replace also looks strange as if it's overwriting characters instead of inserting the "/"

@PVince81
Copy link
Contributor Author

PVince81 commented Sep 27, 2016

Never mind the LDAP issue, I forgot to check out user_ldap app when switching branch.

  • BUG? many avatar folders created for all LDAP users, not only the ones that have logged in.
    @DeepDiver1975 @butonic do we really want that many empty folders ? ^
  • BUG: moved avatar with encryption is not readable

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 5, 2016

rebased for the weird CI failures.

Still need to look at the encryption issues.

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 5, 2016

I have retested with encryption twice with local and LDAP users and it all worked fine. Maybe last time I did something wrong.

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 5, 2016

Okay, so with a setup LDAP server and going to the users page, it will query the avatar of all users displayed on the page which will create empty avatar folders.

Let's see if we can prevent this by checking the last login flag and avoid creating folders for users who never logged in before.

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 5, 2016

Looks like this won't be easily possible. The problem is that even when no avatar exists, we need to return a valid instance of Avatar on which the called might call "get" or "set".
If we'd wanted the folder to be lazily created, we'd need either a LazyAvatar or something like a LazyNonExistingFolder that would create itself once file operations are done on it.
This sounds a bit overcomplicated for not much benefits. Could be solved separately if needed.

@butonic @DeepDiver1975 re-review ? also see text above

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 5, 2016

some really weird failures:

Error: Class 'OCA\Files_External\Lib\Storage\SMB' not found

maybe the executor is is a broken state and needs cleanup?

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 7, 2016

Rebased, hoping for passing CI now

@DeepDiver1975
Copy link
Member

SMB and swift again - atleast smb works locally for me ...

let me kick jenkins

@DeepDiver1975
Copy link
Member

I see this in the logs - maybe related?

An unhandled exception has been thrown:
TypeError: Argument 5 passed to OC\Repair\MoveAvatarOutsideHome::__construct() must be an instance of OC\Repair\IRootFolder, instance of OC\Files\Node\LazyRoot given, called in /home/deepdiver/Development/ownCloud/master/lib/private/Repair.php on line 150 and defined in /home/deepdiver/Development/ownCloud/master/lib/private/Repair/MoveAvatarOutsideHome.php:68
Stack trace:
#0 /home/deepdiver/Development/ownCloud/master/lib/private/Repair.php(150): OC\Repair\MoveAvatarOutsideHome->__construct(Object(OC\AllConfig), Object(OC\DB\Connection), Object(OC\User\Manager), Object(OC\AvatarManager), Object(OC\Files\Node\LazyRoot), Object(OC\L10N\L10N), Object(OC\Log))
#1 /home/deepdiver/Development/ownCloud/master/core/register_command.php(125): OC\Repair::getRepairSteps()
#2 /home/deepdiver/Development/ownCloud/master/lib/private/Console/Application.php(88): require_once('/home/deepdiver...')
#3 /home/deepdiver/Development/ownCloud/master/console.php(93): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/deepdiver/Development/ownCloud/master/occ(11): require_once('/home/deepdiver...')
#5 {main}PHPUnit 5.5.4 by Sebastian Bergmann and contributors.

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 7, 2016

Green now. Merge ?

@DeepDiver1975 DeepDiver1975 merged commit c06f9dc into master Oct 7, 2016
@DeepDiver1975 DeepDiver1975 deleted the moveavatarsoutside branch October 7, 2016 14:48
@butonic butonic mentioned this pull request Nov 8, 2016
3 tasks
@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 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.

4 participants