Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66d85ea0 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

feat: setup appdata folder based on config value

parent 1b9932cd
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ RUN patch -u ${BASE_DIR}/apps/provisioning_api/lib/Controller/UsersController.ph
RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-private.patch
RUN patch -u ${BASE_DIR}/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php -i ${TMP_PATCH_DIR}/034-oidc-bearer-token-auth.patch
#RUN patch -u ${BASE_DIR}/custom_apps/snappymail/app/snappymail/v/2.38.2+murena-20251112/app/libraries/RainLoop/Actions/Contacts.php -i ${TMP_PATCH_DIR}/037-snappymail-contact.patch
RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/038-appdata-folder-based-on-config.patch
RUN rm -rf ${TMP_PATCH_DIR}


+64 −0
Original line number Diff line number Diff line
diff --git a/config/config.sample.php b/config/config.sample.php
index 82acd43e9d9..5620c3c0156 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -2291,6 +2291,15 @@ $CONFIG = [
 	 */
 	'updatedirectory' => '',
 
+	/**
+ 	* Override where Nextcloud stores the ``appdata_INSTANCEID`` directory. Useful
+ 	* when using remote object storage where local system disks provide faster data
+ 	* access. Defaults to `datadirectory` if unset.
+ 	*
+ 	* The Web server user must have write access to this directory.
+ 	*/
+	'appdatadirectory' => '',
+
 	/**
 	 * Block specific files or filenames, disallowing uploads or access (read and write).
 	 * ``.htaccess`` is blocked by default.
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index e058be0663b..fb8fb01d69a 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -429,10 +429,26 @@ class SetupManager implements ISetupManager {
 		foreach ($rootMounts as $rootMountProvider) {
 			$this->mountManager->addMount($rootMountProvider);
 		}
-
+		$this->setupAppData();
 		$this->eventLogger->end('fs:setup:root');
 	}
 
+	private function setupAppData(): void {
+		if ($appdatadirectory = $this->config->getSystemValue('appdatadirectory', null)) {
+			$instanceId = $this->config->getSystemValue('instanceid', null);
+			if ($instanceId === null) {
+				throw new \RuntimeException('no instance id!');
+			}
+			$folderName = 'appdata_' . $instanceId;
+			$arguments = [
+				'datadir' => $appdatadirectory,
+			];
+			$storage = new \OC\Files\Storage\Local($arguments);
+			$mount = new \OC\Files\Mount\MountPoint($storage, $folderName, $arguments);
+			$this->mountManager->addMount($mount);
+		}
+	}
+
 	/**
 	 * Get the user to setup for a path or `null` if the root needs to be setup
 	 *
diff --git a/lib/private/SystemConfig.php b/lib/private/SystemConfig.php
index 7e8946f4d05..b59b979d7b5 100644
--- a/lib/private/SystemConfig.php
+++ b/lib/private/SystemConfig.php
@@ -20,6 +20,7 @@ class SystemConfig {
 	protected const DEFAULT_SENSITIVE_VALUES = [
 		'instanceid' => true,
 		'datadirectory' => true,
+		'appdatadirectory' => true,
 		'dbname' => true,
 		'dbhost' => true,
 		'dbpassword' => true,