diff --git a/lib/BackgroundJob/BackgroundScanner.php b/lib/BackgroundJob/BackgroundScanner.php index 4490bcd3..d60fb98b 100644 --- a/lib/BackgroundJob/BackgroundScanner.php +++ b/lib/BackgroundJob/BackgroundScanner.php @@ -22,6 +22,7 @@ use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; use OCP\Files\Node; +use OCP\IConfig; use OCP\IDBConnection; use Psr\Log\LoggerInterface; @@ -35,6 +36,7 @@ class BackgroundScanner extends TimedJob { protected ItemFactory $itemFactory; private IUserMountCache $userMountCache; private IEventDispatcher $eventDispatcher; + private IConfig $config; private bool $isCLI; public function __construct( @@ -48,6 +50,7 @@ public function __construct( ItemFactory $itemFactory, IUserMountCache $userMountCache, IEventDispatcher $eventDispatcher, + IConfig $config, bool $isCLI ) { parent::__construct($timeFactory); @@ -60,6 +63,7 @@ public function __construct( $this->itemFactory = $itemFactory; $this->userMountCache = $userMountCache; $this->eventDispatcher = $eventDispatcher; + $this->config = $config; $this->isCLI = $isCLI; // Run once per 15 minutes @@ -202,6 +206,7 @@ protected function getSizeLimitExpression(IQueryBuilder $qb) { */ public function getUnscannedFiles() { $dirMimeTypeId = $this->mimeTypeLoader->getId(FileInfo::MIMETYPE_FOLDER); + $instanceId = $this->config->getSystemValue('instanceid', ''); $query = $this->db->getQueryBuilder(); $query->select('fc.fileid') @@ -214,6 +219,7 @@ public function getUnscannedFiles() { $query->expr()->like('path', $query->createNamedParameter('files/%')), $query->expr()->notLike('s.id', $query->createNamedParameter('home::%')) )) + ->andWhere($query->expr()->notLike('fc.path', $query->createNamedParameter("appdata_$instanceId/%"))) ->andWhere($this->getSizeLimitExpression($query)) ->setMaxResults($this->getBatchSize() * 10); diff --git a/tests/BackgroundScannerTest.php b/tests/BackgroundScannerTest.php index d9756d24..22865dce 100644 --- a/tests/BackgroundScannerTest.php +++ b/tests/BackgroundScannerTest.php @@ -21,6 +21,7 @@ use OCP\Files\Folder; use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; +use OCP\IConfig; use OCP\IDBConnection; use Psr\Log\LoggerInterface; use Test\Traits\MountProviderTrait; @@ -104,6 +105,7 @@ private function getBackgroundScanner(): BackgroundScanner { \OC::$server->get(ItemFactory::class), \OC::$server->get(IUserMountCache::class), \OC::$server->get(IEventDispatcher::class), + \OC::$server->get(IConfig::class), false ); }