From 66d85ea04483bbacc48712527036ba94492e1684 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Mar 2026 15:53:40 +0600 Subject: [PATCH 1/7] feat: setup appdata folder based on config value parent PR: https://github.com/nextcloud/server/pull/57747 issue: https://gitlab.e.foundation/e/infra/backlog/-/issues/5299 --- Dockerfile | 1 + .../038-appdata-folder-based-on-config.patch | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 patches/038-appdata-folder-based-on-config.patch diff --git a/Dockerfile b/Dockerfile index e302454..8f4e665 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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} diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch new file mode 100644 index 0000000..f441946 --- /dev/null +++ b/patches/038-appdata-folder-based-on-config.patch @@ -0,0 +1,64 @@ +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, -- GitLab From 8247f9a164ddf7f846015d28a1bdcf7077daa4d1 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Mar 2026 16:02:34 +0600 Subject: [PATCH 2/7] fix: patch file name prefix --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8f4e665..1c86e03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -176,7 +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 cd ${BASE_DIR} && patch -p1 < ${TMP_PATCH_DIR}/038-appdata-folder-based-on-config.patch RUN rm -rf ${TMP_PATCH_DIR} -- GitLab From 288bd3c6b32728bac66e0d68e9b7d7c2cce9dd5e Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Mar 2026 16:18:29 +0600 Subject: [PATCH 3/7] fix: 038 patch file --- Dockerfile | 2 +- .../038-appdata-folder-based-on-config.patch | 27 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c86e03..8f4e665 100644 --- a/Dockerfile +++ b/Dockerfile @@ -176,7 +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 -p1 < ${TMP_PATCH_DIR}/038-appdata-folder-based-on-config.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/038-appdata-folder-based-on-config.patch RUN rm -rf ${TMP_PATCH_DIR} diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch index f441946..17ff554 100644 --- a/patches/038-appdata-folder-based-on-config.patch +++ b/patches/038-appdata-folder-based-on-config.patch @@ -1,8 +1,7 @@ -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 = [ +diff --git config/config.sample.php config/config.sample-new.php +--- config/config.sample.php 2025-02-13 19:30:40 ++++ config/config.sample-new.php 2025-02-13 19:31:40 +@@ -2291,6 +2291,15 @@ */ 'updatedirectory' => '', @@ -18,11 +17,10 @@ index 82acd43e9d9..5620c3c0156 100644 /** * 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 { +diff --git lib/private/Files/SetupManager.php lib/private/Files/SetupManager-new.php +--- lib/private/Files/SetupManager.php 2025-02-13 19:32:40 ++++ lib/private/Files/SetupManager-new.php 2025-02-13 19:33:40 +@@ -429,10 +429,26 @@ foreach ($rootMounts as $rootMountProvider) { $this->mountManager->addMount($rootMountProvider); } @@ -50,11 +48,10 @@ index e058be0663b..fb8fb01d69a 100644 /** * 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 { +diff --git lib/private/SystemConfig.php lib/private/SystemConfig-new.php +--- lib/private/SystemConfig.php 2025-02-13 19:34:40 ++++ lib/private/SystemConfig-new.php 2025-02-13 19:35:40 +@@ -20,6 +20,7 @@ protected const DEFAULT_SENSITIVE_VALUES = [ 'instanceid' => true, 'datadirectory' => true, -- GitLab From 164c74e6835c183424ffb4d02460ab4cb8fb8612 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Mar 2026 16:31:53 +0600 Subject: [PATCH 4/7] fix: 038 patch file --- .../038-appdata-folder-based-on-config.patch | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch index 17ff554..c757930 100644 --- a/patches/038-appdata-folder-based-on-config.patch +++ b/patches/038-appdata-folder-based-on-config.patch @@ -1,11 +1,9 @@ -diff --git config/config.sample.php config/config.sample-new.php ---- config/config.sample.php 2025-02-13 19:30:40 -+++ config/config.sample-new.php 2025-02-13 19:31:40 -@@ -2291,6 +2291,15 @@ - */ +--- config/config.sample.php 2026-03-05 16:23:55.502882136 +0600 ++++ config/config.sample-new.php 2026-03-05 16:24:24.130247452 +0600 +@@ -2292,6 +2292,15 @@ '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. @@ -14,12 +12,12 @@ diff --git config/config.sample.php config/config.sample-new.php + */ + 'appdatadirectory' => '', + - /** ++ /** * Block specific files or filenames, disallowing uploads or access (read and write). * ``.htaccess`` is blocked by default. -diff --git lib/private/Files/SetupManager.php lib/private/Files/SetupManager-new.php ---- lib/private/Files/SetupManager.php 2025-02-13 19:32:40 -+++ lib/private/Files/SetupManager-new.php 2025-02-13 19:33:40 + * +--- lib/private/Files/SetupManager.php 2026-03-05 16:26:59.175816848 +0600 ++++ lib/private/Files/SetupManager-new.php 2026-03-05 16:26:46.271803100 +0600 @@ -429,10 +429,26 @@ foreach ($rootMounts as $rootMountProvider) { $this->mountManager->addMount($rootMountProvider); @@ -48,9 +46,8 @@ diff --git lib/private/Files/SetupManager.php lib/private/Files/SetupManager-new /** * Get the user to setup for a path or `null` if the root needs to be setup * -diff --git lib/private/SystemConfig.php lib/private/SystemConfig-new.php ---- lib/private/SystemConfig.php 2025-02-13 19:34:40 -+++ lib/private/SystemConfig-new.php 2025-02-13 19:35:40 +--- lib/private/SystemConfig.php 2026-03-05 16:30:25.597831789 +0600 ++++ lib/private/SystemConfig-new.php 2026-03-05 16:30:12.022966268 +0600 @@ -20,6 +20,7 @@ protected const DEFAULT_SENSITIVE_VALUES = [ 'instanceid' => true, -- GitLab From 348f5da5628091c99faeedd5cb1f7a5d23cb470c Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Mar 2026 17:31:40 +0600 Subject: [PATCH 5/7] fix: 038 patch file against nc v31.0.10 --- .../038-appdata-folder-based-on-config.patch | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch index c757930..b1f90f0 100644 --- a/patches/038-appdata-folder-based-on-config.patch +++ b/patches/038-appdata-folder-based-on-config.patch @@ -1,21 +1,21 @@ ---- config/config.sample.php 2026-03-05 16:23:55.502882136 +0600 -+++ config/config.sample-new.php 2026-03-05 16:24:24.130247452 +0600 -@@ -2292,6 +2292,15 @@ - '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' => '', +--- config/config.sample.php 2026-03-05 17:28:44.439768653 +0600 ++++ config/config-sample-new.php 2026-03-05 17:28:28.248334226 +0600 +@@ -2089,6 +2089,15 @@ + '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. - * ++/** + * Block a specific file or files and disallow the upload of files with this name. + * This blocks any access to those files (read and write). + * ``.htaccess`` is blocked by default. --- lib/private/Files/SetupManager.php 2026-03-05 16:26:59.175816848 +0600 +++ lib/private/Files/SetupManager-new.php 2026-03-05 16:26:46.271803100 +0600 @@ -429,10 +429,26 @@ @@ -26,7 +26,7 @@ + $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); -- GitLab From f4622c82099d39e231cddbaf03eb8317de7b89c1 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 11 Mar 2026 14:47:43 +0600 Subject: [PATCH 6/7] chore: remove documentation part as per review --- .../038-appdata-folder-based-on-config.patch | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch index b1f90f0..849dc0a 100644 --- a/patches/038-appdata-folder-based-on-config.patch +++ b/patches/038-appdata-folder-based-on-config.patch @@ -1,21 +1,3 @@ ---- config/config.sample.php 2026-03-05 17:28:44.439768653 +0600 -+++ config/config-sample-new.php 2026-03-05 17:28:28.248334226 +0600 -@@ -2089,6 +2089,15 @@ - '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 a specific file or files and disallow the upload of files with this name. - * This blocks any access to those files (read and write). - * ``.htaccess`` is blocked by default. --- lib/private/Files/SetupManager.php 2026-03-05 16:26:59.175816848 +0600 +++ lib/private/Files/SetupManager-new.php 2026-03-05 16:26:46.271803100 +0600 @@ -429,10 +429,26 @@ -- GitLab From 2c6919a250993d5138364f18780ea98db5250332 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 11 Mar 2026 14:56:54 +0600 Subject: [PATCH 7/7] [chore] add patch header for 038 patch file --- patches/038-appdata-folder-based-on-config.patch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patches/038-appdata-folder-based-on-config.patch b/patches/038-appdata-folder-based-on-config.patch index 849dc0a..edd1aa6 100644 --- a/patches/038-appdata-folder-based-on-config.patch +++ b/patches/038-appdata-folder-based-on-config.patch @@ -1,3 +1,9 @@ +From: Fahim +Date: Thu, 05 Mar 2026 16:26:00 +0600 +Subject: [PATCH] Enable appdata folder location can be set up dynamatically + +We want to setup appdata folder dynamatically using config. This is specially needed for objectStore setup, so appdata files can be locally accessable, which minimize loadtime. The `appdatadirectory` new config value is introduced by this patch. + --- lib/private/Files/SetupManager.php 2026-03-05 16:26:59.175816848 +0600 +++ lib/private/Files/SetupManager-new.php 2026-03-05 16:26:46.271803100 +0600 @@ -429,10 +429,26 @@ -- GitLab