Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add uploadsdirectory param
Signed-off-by: Lorenzo Tanganelli <[email protected]>
  • Loading branch information
tanganellilore committed Jun 1, 2023
commit 2063d38cc1fad77a575cbb61e154a4a2d63cd261
39 changes: 36 additions & 3 deletions apps/dav/lib/Upload/UploadHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,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->getConfig();

$allowSymlinks = $config->getSystemValueBool('localstorage.allowsymlinks', false);
$uploadsDirectory = $config->getSystemValue('uploadsdirectory', '');
$user_path = '/' . $user->getUID() . '/uploads';
$absolute_user_path = $rootView->getLocalFile($user_path);

if ($allowSymlinks && $uploadsDirectory != '') {
$upload_user_path = $uploadsDirectory . $user_path;

if (!$rootView->file_exists($user_path) || !is_link($link_user_path) || ($upload_user_path != readlink($absolute_user_path)) ) {

if (!is_dir($upload_user_path)) {
mkdir($upload_user_path, 0750, true);
}

// useful if link is broken due to $upload_user_path changes
if (is_link($absolute_user_path)) {
unlink($absolute_user_path);
} else if (is_dir($absolute_user_path)) {
$rootView->rmdir($user_path);
}
symlink($upload_user_path, $link_user_path);

}

} else {
if (is_link($absolute_user_path)) {
unlink($absolute_user_path);
}
if (!$rootView->file_exists($user_path)) {
$rootView->mkdir($user_path);
}
}
return new View('/' . $user->getUID() . '/uploads');

return new View($user_path);
}

private function getStorage() {
Expand Down
8 changes: 8 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,14 @@
*/
'updatedirectory' => '',

/**
* Override where Nextcloud stores uploads user files while uploading (chunks). Useful in situations
* where the default `<user_id>/uploads` is on network disk like NFS.
* Defaults to the value of `` if unset. Require `localstorage.allowsymlinks` set to `true` because
* impementation require symlink to works.
*/
'uploadsdirectory' => '',

/**
* Blacklist a specific file or files and disallow the upload of files
* with this name. ``.htaccess`` is blocked by default.
Expand Down