-
-
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
Changes from all commits
2063d38
ce192c6
9ef6c95
d2db5a5
113eda6
57803e4
a98604e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |||||
| use OC\Files\Filesystem; | ||||||
| use OC\Files\View; | ||||||
| use OCA\DAV\Connector\Sabre\Directory; | ||||||
| use OCP\IConfig; | ||||||
| use Sabre\DAV\Exception\Forbidden; | ||||||
| use Sabre\DAV\ICollection; | ||||||
|
|
||||||
|
|
@@ -97,10 +98,43 @@ private function getView() { | |||||
| $rootView = new View(); | ||||||
| $user = \OC::$server->getUserSession()->getUser(); | ||||||
| Filesystem::initMountPoints($user->getUID()); | ||||||
| if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { | ||||||
| $rootView->mkdir('/' . $user->getUID() . '/uploads'); | ||||||
|
|
||||||
| $config = \OC::$server->get(IConfig::class); | ||||||
|
|
||||||
| $allowSymlinks = $config->getSystemValueBool('localstorage.allowsymlinks', false); | ||||||
| $uploadsPath = $config->getSystemValueString('uploads_path', ''); | ||||||
| $userPath = '/' . $user->getUID() . '/uploads'; | ||||||
| $absoluteUserPath = $rootView->getLocalFile($userPath); | ||||||
|
|
||||||
| if ($allowSymlinks && $uploadsPath !== '' && $absoluteUserPath) { | ||||||
| $uploadUserPath = $uploadsPath . $userPath; | ||||||
|
|
||||||
| if (!$rootView->file_exists($userPath) || !is_link($absoluteUserPath) || ($uploadUserPath != realpath($absoluteUserPath)) ) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do we check for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||
|
|
||||||
| if (!is_dir($uploadUserPath)) { | ||||||
| mkdir($uploadUserPath, 0750, true); | ||||||
| } | ||||||
|
|
||||||
| // useful if link is broken due to $uploadUserPath changes | ||||||
| if (is_link($absoluteUserPath)) { | ||||||
| unlink($absoluteUserPath); | ||||||
| } elseif (is_dir($absoluteUserPath)) { | ||||||
| $rootView->rmdir($userPath); | ||||||
| } | ||||||
| symlink($uploadUserPath, $absoluteUserPath); | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| } else { | ||||||
| if ($absoluteUserPath && is_link($absoluteUserPath)) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More explicit check?
Suggested change
|
||||||
| unlink($absoluteUserPath); | ||||||
| } | ||||||
| if (!$rootView->file_exists($userPath)) { | ||||||
| $rootView->mkdir($userPath); | ||||||
| } | ||||||
| } | ||||||
| return new View('/' . $user->getUID() . '/uploads'); | ||||||
|
|
||||||
| return new View($userPath); | ||||||
| } | ||||||
|
|
||||||
| private function getStorage() { | ||||||
|
|
||||||
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?