Skip to content

Commit 1f60b7e

Browse files
committed
(feat) setup appdata folder based on config
Signed-off-by: Akhil <akhil@e.email>
1 parent 1285c8c commit 1f60b7e

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

config/config.sample.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,15 @@
22912291
*/
22922292
'updatedirectory' => '',
22932293

2294+
/**
2295+
* Override where Nextcloud stores the ``appdata_INSTANCEID`` directory. Useful
2296+
* when using remote object storage where local system disks provide faster data
2297+
* access. Defaults to `datadirectory` if unset.
2298+
*
2299+
* The Web server user must have write access to this directory.
2300+
*/
2301+
'appdatadirectory' => '',
2302+
22942303
/**
22952304
* Block specific files or filenames, disallowing uploads or access (read and write).
22962305
* ``.htaccess`` is blocked by default.

lib/private/Files/SetupManager.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,26 @@ public function setupRoot(): void {
429429
foreach ($rootMounts as $rootMountProvider) {
430430
$this->mountManager->addMount($rootMountProvider);
431431
}
432-
432+
$this->setupAppData();
433433
$this->eventLogger->end('fs:setup:root');
434434
}
435435

436+
private function setupAppData(): void {
437+
if ($appdatadirectory = $this->config->getSystemValue('appdatadirectory', null)) {
438+
$instanceId = $this->config->getSystemValue('instanceid', null);
439+
if ($instanceId === null) {
440+
throw new \RuntimeException('no instance id!');
441+
}
442+
$folderName = 'appdata_' . $instanceId;
443+
$arguments = [
444+
'datadir' => $appdatadirectory,
445+
];
446+
$storage = new \OC\Files\Storage\Local($arguments);
447+
$mount = new \OC\Files\Mount\MountPoint($storage, $folderName, $arguments);
448+
$this->mountManager->addMount($mount);
449+
}
450+
}
451+
436452
/**
437453
* Get the user to setup for a path or `null` if the root needs to be setup
438454
*

lib/private/SystemConfig.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SystemConfig {
2020
protected const DEFAULT_SENSITIVE_VALUES = [
2121
'instanceid' => true,
2222
'datadirectory' => true,
23+
'appdatadirectory' => true,
2324
'dbname' => true,
2425
'dbhost' => true,
2526
'dbpassword' => true,

0 commit comments

Comments
 (0)