Skip to content

Commit

Permalink
make nextcloud create external storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored and ibizaman committed Jan 16, 2025
1 parent 7ebea7c commit af123bc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/services/nextcloud-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions modules/services/nextcloud-server/docs/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions patches/nextcloudexternalstorage.patch
Original file line number Diff line number Diff line change
@@ -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']);
}
}

0 comments on commit af123bc

Please sign in to comment.