diff --git a/apps/files_trashbin/lib/Sabre/RootCollection.php b/apps/files_trashbin/lib/Sabre/RootCollection.php
index e425fb448e28b3e6eb994aa5b7e5e48da537aa2f..be31d200f71045b1714647b67757947215fda7ec 100644
--- a/apps/files_trashbin/lib/Sabre/RootCollection.php
+++ b/apps/files_trashbin/lib/Sabre/RootCollection.php
@@ -23,14 +23,17 @@ declare(strict_types=1);
  */
 namespace OCA\Files_Trashbin\Sabre;
 
+use OCP\IConfig;
 use Sabre\DAV\INode;
 use Sabre\DAVACL\AbstractPrincipalCollection;
 use Sabre\DAVACL\PrincipalBackend;
 
 class RootCollection extends AbstractPrincipalCollection {
 
-	public function __construct(PrincipalBackend\BackendInterface $principalBackend) {
+	public function __construct(PrincipalBackend\BackendInterface $principalBackend, IConfig $config) {
 		parent::__construct($principalBackend, 'principals/users');
+
+		$this->disableListing = !$config->getSystemValue('debug', false);
 	}
 
 	/**
diff --git a/apps/files_versions/lib/Sabre/RootCollection.php b/apps/files_versions/lib/Sabre/RootCollection.php
index 397f1c55891522b9b42f4ea5620bf0734a6e4820..ca5979573b5490e11f4d4bd28a5453a737f210c7 100644
--- a/apps/files_versions/lib/Sabre/RootCollection.php
+++ b/apps/files_versions/lib/Sabre/RootCollection.php
@@ -23,6 +23,7 @@
 namespace OCA\Files_Versions\Sabre;
 
 use OCP\Files\IRootFolder;
+use OCP\IConfig;
 use Sabre\DAV\INode;
 use Sabre\DAVACL\AbstractPrincipalCollection;
 use Sabre\DAVACL\PrincipalBackend;
@@ -33,10 +34,13 @@ class RootCollection extends AbstractPrincipalCollection {
 	private $rootFolder;
 
 	public function __construct(PrincipalBackend\BackendInterface $principalBackend,
-								IRootFolder $rootFolder) {
+								IRootFolder $rootFolder,
+								IConfig $config) {
 		parent::__construct($principalBackend, 'principals/users');
 
 		$this->rootFolder = $rootFolder;
+
+		$this->disableListing = !$config->getSystemValue('debug', false);
 	}
 
 	/**