diff --git a/modules/services/nextcloud-server.nix b/modules/services/nextcloud-server.nix index 75eeb99..c689ecd 100644 --- a/modules/services/nextcloud-server.nix +++ b/modules/services/nextcloud-server.nix @@ -685,7 +685,11 @@ in # not loading to realize those scripts are inserted by extensions. Doh. services.nextcloud = { enable = true; - package = nextcloudPkg; + package = nextcloudPkg.overrideAttrs (old: { + patches = [ + ../../patches/nextcloudexternalstorage.patch + ]; + }); datadir = cfg.dataDir; diff --git a/modules/services/nextcloud-server/docs/default.md b/modules/services/nextcloud-server/docs/default.md index 4a15dd7..12947fb 100644 --- a/modules/services/nextcloud-server/docs/default.md +++ b/modules/services/nextcloud-server/docs/default.md @@ -457,6 +457,12 @@ which is well suited for randomly accessing small files like thumbnails. On the other side, a spinning hard drive can store more data which is well suited for storing user data. +This Nextcloud module includes a patch that allows the external storage +to actually create the local path. Normally, when login in for the first time, +the user will be greeted with an error saying the external storage path does +not exist. One must then create it manually. With this patch, Nextcloud +creates the path. + ### Enable OnlyOffice App {#services-nextcloudserver-usage-onlyoffice} The following snippet installs and enables the [Only diff --git a/patches/nextcloudexternalstorage.patch b/patches/nextcloudexternalstorage.patch new file mode 100644 index 0000000..d5550d2 --- /dev/null +++ b/patches/nextcloudexternalstorage.patch @@ -0,0 +1,21 @@ +diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php +index 8fec24996891f..57b2980f1a43f 100644 +--- a/lib/private/Files/Storage/Local.php ++++ b/lib/private/Files/Storage/Local.php +@@ -101,9 +101,13 @@ public function __construct($arguments) { + $this->unlinkOnTruncate = $this->config->getSystemValueBool('localstorage.unlink_on_truncate', false); + + if (isset($arguments['isExternal']) && $arguments['isExternal'] && !$this->stat('')) { +- // data dir not accessible or available, can happen when using an external storage of type Local +- // on an unmounted system mount point +- throw new StorageNotAvailableException('Local storage path does not exist "' . $this->getSourcePath('') . '"'); ++ ++ if (!$this->mkdir('')) { ++ // data dir not accessible or available, can happen when using an external storage of type Local ++ // on an unmounted system mount point ++ throw new StorageNotAvailableException('Local storage path does not exist and could not create it "' . $this->getSourcePath('') . '"'); ++ } ++ \OC::$server->get(LoggerInterface::class)->warning('created local storage path ' . $this->getSourcePath(''), ['app' => 'core']); + } + } +