-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add uploadsdirectory param #38506
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 uploadsdirectory param #38506
Conversation
40e6825 to
4619c80
Compare
come-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments on code
52d9724 to
c7bea9c
Compare
come-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments on codestyle.
Codewise this looks good to me. I’d just like other opinion on the chosen solution to rely on symlink for this, does anyone see this causing trouble in the future?
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]>
Signed-off-by: Lorenzo Tanganelli <[email protected]> Signed-off-by: Lorenzo Tanganelli <[email protected]>
329cea1 to
a98604e
Compare
|
Thnaks @come-nc , the other alternative, is to rework where chunk uploads are store, without usage of symlink, but I don't have a lot fo experience on nextcloud codebase to identfy where uploads folder is used (i suppose on ChunkPlugin, but i don't know if somewhere else) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure about the current logic, I left a few comments to make is more readable.
Also, did you consider changing the code to directly write files to the PHP tmp folder? Probably a bigger change, but it would remove the need of creating and maintaining symlinks.
Or we could also append each successive chunks to the same final file, which would also reduce the read/write to 1. But chunks are probably coming unordered.
| $userPath = '/' . $user->getUID() . '/uploads'; | ||
| $absoluteUserPath = $rootView->getLocalFile($userPath); | ||
|
|
||
| if ($allowSymlinks && $uploadsPath !== '' && $absoluteUserPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More explicit check?
| if ($allowSymlinks && $uploadsPath !== '' && $absoluteUserPath) { | |
| if ($allowSymlinks && $uploadsPath !== '' && $absoluteUserPath !== null) { |
| if ($allowSymlinks && $uploadsPath !== '' && $absoluteUserPath) { | ||
| $uploadUserPath = $uploadsPath . $userPath; | ||
|
|
||
| if (!$rootView->file_exists($userPath) || !is_link($absoluteUserPath) || ($uploadUserPath != realpath($absoluteUserPath)) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do we check for !$rootView->file_exists($userPath)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would invert the if/else statement to have a more readable condition.
| if (!$rootView->file_exists($userPath) || !is_link($absoluteUserPath) || ($uploadUserPath != realpath($absoluteUserPath)) ) { | |
| if ($rootView->file_exists($userPath) && is_link($absoluteUserPath) && ($uploadUserPath === realpath($absoluteUserPath)) ) { |
| } | ||
|
|
||
| } else { | ||
| if ($absoluteUserPath && is_link($absoluteUserPath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More explicit check?
| if ($absoluteUserPath && is_link($absoluteUserPath)) { | |
| if ($absoluteUserPath !== null && is_link($absoluteUserPath)) { |
|
Could you also check if adding tests is doable? |
|
As already commented, we can think to use directly a path like tmp for php, but i don't know which function need to be rewrite, in each piece/application. If everything is under this repo, i can check it, but i don't know all dependecies |
|
The use case of having the uploads go somewhere else is already supported by setting the When set, uploads will go into server/lib/private/Files/Mount/CacheMountProvider.php Lines 54 to 70 in 426c034
|
|
Thanks @icewind1991, Yes i notice it when i work in the new PR, but this means that one config cover two different path. What so you think? If yes we can consider only my last PR and close this one. From my point of view, other PR #38587 it's much correct (and will be documented) |
|
Close in favour of #38587 |
Summary
This PR will address the feature above, adding new config parameter and manage it.
The "smart" solution adopted is to use the conjunction of param that already exists
localstorage.allowsymlinksand new config paramuploadsdirectory.The idea is to use a symlink to avoid the rework in all files/functions where
<user_id>/uploadsit's used.The only piece of code that require changes is
apps/dav/lib/Upload/UploadHome.phpthat check iflocalstorage.allowsymlinksis true anduploadsdirectoryis setted, if yes we create symlink (if not already exists), if not, we continue to use the current implementation.In case of user changes
localstorage.allowsymlinksoruploadsdirectory, we will delete current link (or directory) and recreate it (link or dir based on settings).TODO
Checklist