Skip to content

Commit 60ceaca

Browse files
split cache_path and uploads_path
Signed-off-by: Lorenzo Tanganelli <[email protected]>
1 parent fa23698 commit 60ceaca

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

config/config.sample.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,13 @@
18971897
*/
18981898
'updatedirectory' => '',
18991899

1900+
/**
1901+
* Override where Nextcloud stores uploaded user files while uploading (chunks). Useful in situations
1902+
* where the default `<user_id>/uploads` is on network disk like NFS.
1903+
* Defaults to the value of '' if unset.
1904+
*/
1905+
'uploads_path' => '',
1906+
19001907
/**
19011908
* Blacklist a specific file or files and disallow the upload of files
19021909
* 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
@@ -53,19 +53,24 @@ public function __construct(IConfig $config) {
5353
*/
5454
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
5555
$cacheBaseDir = $this->config->getSystemValueString('cache_path', '');
56+
$mounts = [];
5657
if ($cacheBaseDir !== '') {
5758
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID();
5859
if (!file_exists($cacheDir)) {
5960
mkdir($cacheDir, 0770, true);
60-
mkdir($cacheDir . '/uploads', 0770, true);
6161
}
62-
63-
return [
64-
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class),
65-
new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class)
66-
];
67-
} else {
68-
return [];
62+
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class);
6963
}
64+
65+
$uploadsPath = $this->config->getSystemValueString('uploads_path', $this->config->getSystemValueString('cache_path', ''));
66+
if ($uploadsPath !== '') {
67+
$uploadsDir = rtrim($uploadsPath, '/') . '/' . $user->getUID() . '/uploads';
68+
if (!file_exists($uploadsDir)) {
69+
mkdir($uploadsDir, 0770, true);
70+
}
71+
$mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $uploadsDir], $loader, null, null, self::class);
72+
}
73+
74+
return $mounts;
7075
}
7176
}

0 commit comments

Comments
 (0)