You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ext storage] Rely on numeric_id, store config in DB, improve config format #11261
This needs a lot of code gymnastics to get to the right information and it also increases the risk of misunderstanding and introducing bugs this way.
I suggest to provide a new class to contain that data, like:
class MountPoint {
private$type; // personal or systemprivate$applicable; // array of users/groups to which the mount point appliesprivate$mountPath; // path to the mount point in the user's file systemprivate$priority;
// ...
}
This is just half of the pain.
The other half is the way how the config is stored in mount.json.
If you create a SFTP storage for two users, the config looks like this:
The config is stored multiple times for every user/group.
There is logic to magically merge the config to show as a single row in the UI... it merges the configs if all the parameters (including password) are the same. Else they will appear as separate entries.
The multi-stacked arrays are very difficult to handle, I agree. I do have a suggestion for the JSON output though - instead of storing it as 'applicable type -> applicable -> storage -> class/options...', store it as 'storage -> class/options/applicable...'. For example:
The only drawback is that finding applicable mount points becomes harder - the code needs to iterate through every storage and check if it is applicable.
Alternatively, what about storing this in the database? oc_files_external_storages to define the storages, oc_files_external_params to define parameters of each storage, and oc_files_external_map to map the storages to their applicable users/groups:
oc_files_external_storages
==========================
id | class
-------------------------------
0 | \\OC\\Files\\Storage\\SFTP
oc_files_external_params
========================
id | storage_id | name | value
---------------------------------------------------------------------------------
0 | 0 | host | localhost
1 | 0 | user | vincent
2 | 0 | password | NULL
3 | 0 | root | \/home\/vincent\/temp\/sftpmount
4 | 0 | password_encrypted | MTAxMmZiYmMxNGRmYjM3ZH8hV2NliG6z0wi7lCxy+tY=
oc_files_external_map
=====================
id | storage_id | type | value
---------------------------------------
0 | 0 | user | user1
1 | 0 | user | root
Storing in the database might make more sense, yes. It was already mentioned several times in discussions. I also like that you added the storage column which can be mapped to the matching oc_storages table instead of doing the usual "generate the storage id by concatenning settings" magic to find the matching entry.
@icewind1991 do you think it's possible in any way to make mounting the storages depend on the numeric id instead of storage string id ? How complex would the change be ?
I think the main usage of the string id atm is the storage<-> cache mapping, currently a storage calculates it's string id, looks up the numeric id and uses that for cache operations.
We would need to adjust every point a where a mount is created and inject the numeric storage id (non trivial for non-files_external since we dont keep track of numeric storage id's for things like home storages)
Activity
PVince81 commentedon Sep 23, 2014
This is especially important if external storage is going to play a more important role in the future.
@MTRichards @craigpg @karlitschek
CC @fernandoruiz @jmaciasportela
PVince81 commentedon Sep 23, 2014
This is just half of the pain.
The other half is the way how the config is stored in
mount.json.If you create a SFTP storage for two users, the config looks like this:
The config is stored multiple times for every user/group.
There is logic to magically merge the config to show as a single row in the UI... it merges the configs if all the parameters (including password) are the same. Else they will appear as separate entries.
karlitschek commentedon Sep 23, 2014
yes. agreed
RobinMcCorkell commentedon Sep 23, 2014
The multi-stacked arrays are very difficult to handle, I agree. I do have a suggestion for the JSON output though - instead of storing it as 'applicable type -> applicable -> storage -> class/options...', store it as 'storage -> class/options/applicable...'. For example:
The only drawback is that finding applicable mount points becomes harder - the code needs to iterate through every storage and check if it is applicable.
Alternatively, what about storing this in the database?
oc_files_external_storagesto define the storages,oc_files_external_paramsto define parameters of each storage, andoc_files_external_mapto map the storages to their applicable users/groups:Or something to that effect
PVince81 commentedon Sep 23, 2014
Storing in the database might make more sense, yes. It was already mentioned several times in discussions. I also like that you added the
storagecolumn which can be mapped to the matchingoc_storagestable instead of doing the usual "generate the storage id by concatenning settings" magic to find the matching entry.PVince81 commentedon Oct 31, 2014
Related: #11830 about the unstable storage string id.
PVince81 commentedon Oct 31, 2014
I think
oc_files_external_storagecould simply be the existingoc_storagestable, but extended with atypecolumn.We'd simply use the
numeric_idfromoc_storagesto map to the configs.PVince81 commentedon Oct 31, 2014
Updated proposal:
oc_storages
oc_files_external_params
oc_files_external_applicable
30 remaining items
PVince81 commentedon Aug 10, 2015
This is the ticket for moving mount.json to the DB. As discussed with @DeepDiver1975, moving to 8.2.
From what I heard @Xenopathic will work on it soon, so assigning him.
PVince81 commentedon Aug 10, 2015
I hope we can totally get rid of the storage id string in the process as it will solve many issues.
PVince81 commentedon Aug 10, 2015
@icewind1991 do you think it's possible in any way to make mounting the storages depend on the numeric id instead of storage string id ? How complex would the change be ?
icewind1991 commentedon Aug 10, 2015
I think the main usage of the string id atm is the storage<-> cache mapping, currently a storage calculates it's string id, looks up the numeric id and uses that for cache operations.
We would need to adjust every point a where a mount is created and inject the numeric storage id (non trivial for non-files_external since we dont keep track of numeric storage id's for things like home storages)
RobinMcCorkell commentedon Aug 10, 2015
We should try and get rid of
getId()on the storage implementation itself, it's awkward to have to construct the storage to get its ID. That leads to easy-to-break code such as https://github.com/owncloud/core/blob/master/apps/files_external/lib/config.php#L971-L980. Especially with session-based credentials, some storages will reject being constructed entirely, so we can never correctly get the ID of such storages.PVince81 commentedon Nov 6, 2015
Moving the the database as a first step (independent from old storage ids, for now): #20354
PVince81 commentedon Dec 18, 2015
Also the new oc_mounts table will make it possible to do reverse lookups: #15166
PVince81 commentedon Feb 12, 2016
9.0 code has the storages in the database and a mounts table, yay!
This is done.
lock commentedon Aug 6, 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.