Skip to content

Commit 605863b

Browse files
tanganellilorekesselb
authored andcommitted
split cache_path and uploads_path
Signed-off-by: Lorenzo Tanganelli <[email protected]>
1 parent 250bb12 commit 605863b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

config/config.sample.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,13 @@
19661966
*/
19671967
'updatedirectory' => '',
19681968

1969+
/**
1970+
* Override where Nextcloud stores uploaded user files while uploading (chunks). Useful in situations
1971+
* where the default `<user_id>/uploads` is on network disk like NFS.
1972+
* Defaults to the value of '' if unset.
1973+
*/
1974+
'uploads_path' => '',
1975+
19691976
/**
19701977
* Blacklist a specific file or files and disallow the upload of files
19711978
* with this name. ``.htaccess`` is blocked by default.

lib/private/Files/Mount/CacheMountProvider.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@ public function __construct(IConfig $config) {
3939
*/
4040
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
4141
$cacheBaseDir = $this->config->getSystemValueString('cache_path', '');
42+
$mounts = [];
4243
if ($cacheBaseDir !== '') {
4344
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID();
4445
if (!file_exists($cacheDir)) {
4546
mkdir($cacheDir, 0770, true);
46-
mkdir($cacheDir . '/uploads', 0770, true);
4747
}
48-
49-
return [
50-
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class),
51-
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class)
52-
];
53-
} else {
54-
return [];
48+
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class);
5549
}
50+
51+
$uploadsPath = $this->config->getSystemValueString('uploads_path', $this->config->getSystemValueString('cache_path', ''));
52+
if ($uploadsPath !== '') {
53+
$uploadsDir = rtrim($uploadsPath, '/') . '/' . $user->getUID() . '/uploads';
54+
if (!file_exists($uploadsDir)) {
55+
mkdir($uploadsDir, 0770, true);
56+
}
57+
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $uploadsDir], $loader, null, null, self::class);
58+
}
59+
60+
return $mounts;
5661
}
5762
}

0 commit comments

Comments
 (0)