Skip to content

Commit

Permalink
split cache_path and uploads_path
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Tanganelli <lorenzo.tanganelli@hotmail.it>
  • Loading branch information
tanganellilore committed Jun 2, 2023
1 parent fa23698 commit 20159b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,13 @@
*/
'updatedirectory' => '',

/**
* Override where Nextcloud stores uploaded 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.
*/
'uploads_path' => '',

/**
* Blacklist a specific file or files and disallow the upload of files
* with this name. ``.htaccess`` is blocked by default.
Expand Down
20 changes: 13 additions & 7 deletions lib/private/Files/Mount/CacheMountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,25 @@ public function __construct(IConfig $config) {
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$cacheBaseDir = $this->config->getSystemValueString('cache_path', '');
$mounts = [];
if ($cacheBaseDir !== '') {
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID();
if (!file_exists($cacheDir)) {
mkdir($cacheDir, 0770, true);
mkdir($cacheDir . '/uploads', 0770, true);
}

return [
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class),
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class)
];
} else {
return [];
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class);
}

$uploadsPath = $this->config->getSystemValueString('uploads_path', '');
if ($uploadsPath !== '') {
$uploadsDir = rtrim($uploadsPath, '/') . '/' . $user->getUID();
if (!file_exists($uploadsDir)) {
mkdir($uploadsDir, 0770, true);
}
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => uploadsDir . '/uploads'], $loader, null, null, self::class);
}

return $mounts;
}
}

0 comments on commit 20159b2

Please sign in to comment.