Skip to content

Introducing AppData - #1306

Merged
LukasReschke merged 14 commits into
masterfrom
simplefs
Oct 6, 2016
Merged

Introducing AppData#1306
LukasReschke merged 14 commits into
masterfrom
simplefs

Conversation

@rullzer

@rullzerrullzer commented Sep 7, 2016

Copy link
Copy Markdown
Member

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

@rullzerrullzer added this to the Nextcloud 11.0 milestone Sep 7, 2016

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
MemberAuthor

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

@LukasReschkeLukasReschke mentioned this pull request Sep 9, 2016
9 tasks
@rullzer
rullzerforce-pushed the simplefs branch 4 times, most recently from 3defcd2 to 015a8f4CompareSeptember 12, 2016 13:57
@rullzerrullzer added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 12, 2016
@rullzer

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
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 ;)

@MorrisJobkeMorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Sep 13, 2016
@rullzer
rullzerforce-pushed the simplefs branch 2 times, most recently from 6ff6af3 to 85e6797CompareSeptember 13, 2016 12:44
@rullzer

rullzer commented Sep 13, 2016

Copy link
Copy Markdown
MemberAuthor
  • Skip if avatars are disabled

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

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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.

* 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

codecov-io commented Oct 5, 2016

Copy link
Copy Markdown

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 CoverageFile Path
0%lib/private/legacy/util.php
0%newlib/private/Repair/NC11/MoveAvatarBackgroundJob.php
0%lib/private/Server.php
0%lib/private/Repair.php
0%lib/composer/composer/autoload_classmap.php
0%newlib/private/Repair/NC11/MoveAvatars.php
••••• 50%lib/private/AvatarManager.php
••••••• 75%newlib/private/Files/AppData/AppData.php
•••••••••• 100%lib/private/Avatar.php
•••••••••• 100%newlib/private/Files/SimpleFS/SimpleFolder.php

Review all 16 files changed

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

@rullzer

Copy link
Copy Markdown
MemberAuthor

Fixed. Review time!

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
Member

👍

@MorrisJobkeMorrisJobke 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
Copy Markdown
Member

LGTM

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

Labels

4. to releaseReady to be released and/or waiting for tests to finishenhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@rullzer@mmattel@MorrisJobke@LukasReschke@phsc84@codecov-io@nickvergessen@icewind1991@ChristophWurst@blizzz@juliusknorr