aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@yahoo.fr>2023-08-03 23:09:17 +0200
committerSimon L <szaimen@e.mail.de>2023-08-29 11:04:31 +0200
commit8d1a3daa3fd7d1a4ecb7934662a76266a02ce225 (patch)
tree04c7d45698d887d03f532e4788b7e6cf94574a4e /lib
parent6f520f23046e74c07b1f7179abba1097af3e0c65 (diff)
downloadnextcloud-server-8d1a3daa3fd7d1a4ecb7934662a76266a02ce225.tar.gz
nextcloud-server-8d1a3daa3fd7d1a4ecb7934662a76266a02ce225.zip
Allow ext storage Local to go unavailable
Whenever an external storage of type Local points at a non-existing directory, process this as a StorageNotAvailable instead of returning 404. This makes desktop clients ignore the folder instead of deleting it when it becomes unavailable. The code change was limited to external storages to avoid issues during setup and with the default home storage. Signed-off-by: Vincent Petry <pvince81@yahoo.fr>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Local.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 02708ed4f7d..fdc30b49259 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -51,6 +51,7 @@ use OCP\Files\ForbiddenException;
use OCP\Files\GenericFileException;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\Storage\IStorage;
+use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\Util;
use Psr\Log\LoggerInterface;
@@ -95,6 +96,12 @@ class Local extends \OC\Files\Storage\Common {
// support Write-Once-Read-Many file systems
$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('') . '"');
+ }
}
public function __destruct() {