diff --git a/config/config.sample.php b/config/config.sample.php index 288ea7e4a9b2f..3a398734d534c 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1966,6 +1966,13 @@ */ 'updatedirectory' => '', +/** + * Override where Nextcloud stores uploaded user files while uploading (chunks). Useful in situations + * where the default `/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. diff --git a/lib/private/Files/Mount/CacheMountProvider.php b/lib/private/Files/Mount/CacheMountProvider.php index 27c7eec9da34f..c794cf8f38b04 100644 --- a/lib/private/Files/Mount/CacheMountProvider.php +++ b/lib/private/Files/Mount/CacheMountProvider.php @@ -39,19 +39,24 @@ 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); } + $mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class); + } - 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 []; + $uploadsPath = $this->config->getSystemValueString('uploads_path', $this->config->getSystemValueString('cache_path', '')); + if ($uploadsPath !== '') { + $uploadsDir = rtrim($uploadsPath, '/') . '/' . $user->getUID() . '/uploads'; + if (!file_exists($uploadsDir)) { + mkdir($uploadsDir, 0770, true); + } + $mounts[] = new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $uploadsDir], $loader, null, null, self::class); } + + return $mounts; } }