Skip to content

Conversation

@rullzer
Copy link
Member

@rullzer rullzer commented Sep 7, 2016

Follow up of #1039
Implementing #136

This PR introduces an AppData folder. Basically the file variant of app tables. Sometimes you need to store data but where to put it. Or we want a more efficient way to store the data.

For example:

  • Avatars are now stored directly in the user directory data/userid/avatar.jpg etc. It might make sense to have 1 place for all the avatars. data/<appdata>/avatars/<userid>/avatar.jpg. It could be that your user mounts are on slow (but huge) storage and you want the avatars to be serverd blazing fast.
  • Previews: In order to share previews properly we should store them by fileid in a generic place. Not in the user folder. That will break preview sharing for shared storage etc.
  • Themeing: Right now it put themed files under data/ a better place would of course be data/<appdata>/theming/icons/<icon>.svg etc.

Right now this uses the very limited simpleFS (see #1039). And we use the instanceid as appdatafolder. Which means:

  • An IAppData is chrooted to data/<instanceid>/<appid> this means it can't escape
  • A simpleFS is mapped on top of that
  • The root of the simplefs can only contain folder
  • A folder in a simpleFS can only contain files

This is limiting. I know. But giving more freedom is always easier than reducing it. Plus I think this should be fine for most apps to start with.

Right now this is just mapped on our normal fs. But those abstraction allow this to be improved in the future.

Todo:

  • AppData folder should be appdata_instanceid
  • Make sure users with that name fails hard
  • Mark all as experimental so we can still change for NC12
  • Rename classes (File/Folder/Root clash way to much)
  • Make lazy
  • Tests
  • Proper DI like L10N

Avatar releated todo:

  • Fix tests
  • Migration script

@rullzer rullzer added enhancement 2. developing Work in progress labels Sep 7, 2016
@rullzer rullzer added this to the Nextcloud 11.0 milestone Sep 7, 2016

/** @var string $instanceId */
try {
$appDataFolder = $this->rootFolder->get($instanceId);
Copy link
Member

Choose a reason for hiding this comment

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

imo it would be nices to have something like appdata_$instanceid as the folder name, makes it clear to the admin what that weirdly named folder is

Copy link
Member

Choose a reason for hiding this comment

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

Also can we add some magic to ensure that a user with that name doesn't get that folder? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes was actually also thinking about that.
Of course we can do that

Copy link
Member Author

Choose a reason for hiding this comment

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

Well it would be kind of hard to do it for ldap etc for example. But I'm sure we can do it somehwere when we create the users folder

Copy link
Member Author

Choose a reason for hiding this comment

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

@icewind1991 should we just test for this in the initMountPoints function? that if the userId is equal to appdata_<instanceid> throw exception?

Copy link
Member

Choose a reason for hiding this comment

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

copySkeleton seems like the best place

@mmattel
Copy link
Contributor

mmattel commented Sep 8, 2016

That will break preview sharing for shared storage etc.

Why not putting all the previews into the database?
Space consumption is more or less the same. Eases access control (access by user or group identification).

@rullzer
Copy link
Member Author

rullzer commented Sep 8, 2016

@mmattel no that is way to much data. We also don't store all the files just in the db.

@LukasReschke LukasReschke mentioned this pull request Sep 9, 2016
9 tasks
@rullzer rullzer force-pushed the simplefs branch 4 times, most recently from 3defcd2 to 015a8f4 Compare September 12, 2016 13:57
@rullzer rullzer added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 12, 2016
@rullzer
Copy link
Member Author

rullzer commented Sep 12, 2016

Review time!

CC: @icewind1991 @nickvergessen @MorrisJobke @LukasReschke

try {
$appDataFolder = $this->rootFolder->newFolder($name);
} catch (NotPermittedException $e) {
// Log
Copy link
Member

Choose a reason for hiding this comment

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

/me sees no logging here and below ;)

@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Sep 13, 2016
@rullzer rullzer force-pushed the simplefs branch 2 times, most recently from 6ff6af3 to 85e6797 Compare September 13, 2016 12:44
@rullzer
Copy link
Member Author

rullzer commented Sep 13, 2016

  • Skip if avatars are disabled

\OC::$server->getUserManager(),
\OC::$server->getGroupManager()
),
new MoveAvatars(
Copy link
Member

Choose a reason for hiding this comment

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

Dont register, when the config is disabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather not introduce logic in that function. To not complicate things.

rullzer added 13 commits October 5, 2016 11:00
* Introduce simpleFS
* Introduce IAppData
* Introduce AppData Factory to get your AppData folder
* Update FileDisplayResponse

* AppData implements a ISimpleRoot but lazy. So only if an apps starts
  to access data will stuff get initialized

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Fix AvatarTest

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
* Skip move avatar if avatars disabled

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@codecov-io
Copy link

codecov-io commented Oct 5, 2016

Current coverage is 30.64% (diff: 52.43%)

Merging #1306 into master will decrease coverage by 25.27%

@@             master      #1306   diff @@
==========================================
  Files          1064       1087      +23   
  Lines         60691      60456     -235   
  Methods        6812       6879      +67   
  Messages          0          0            
  Branches          0          0            
==========================================
- Hits          33937      18525   -15412   
- Misses        26754      41931   +15177   
  Partials          0          0            

Sunburst

Diff Coverage File Path
0% lib/private/legacy/util.php
0% new lib/private/Repair/NC11/MoveAvatarBackgroundJob.php
0% lib/private/Server.php
0% lib/private/Repair.php
0% lib/composer/composer/autoload_classmap.php
0% new lib/private/Repair/NC11/MoveAvatars.php
••••• 50% lib/private/AvatarManager.php
••••••• 75% new lib/private/Files/AppData/AppData.php
•••••••••• 100% lib/private/Avatar.php
•••••••••• 100% new lib/private/Files/SimpleFS/SimpleFolder.php

Review all 16 files changed

Powered by Codecov. Last update 8dafcab...316db0a

@rullzer
Copy link
Member Author

rullzer commented Oct 5, 2016

Fixed. Review time!

* @return ISimpleFolder
* @since 9.2.0
*/
public function newFolder($name);
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Done

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@MorrisJobke
Copy link
Member

👍

@MorrisJobke MorrisJobke added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 5, 2016
@LukasReschke
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.