Skip to content

Commit a293480

Browse files
artongemgallien
authored andcommitted
feat(scanner): enable use of a setting to disable DB transaction
while doing a files scan from storage, we may want not to use DB transactions enable the use of a setting for that define filescanner_no_transactions in system config to enable this (i.e. in config.php) Signed-off-by: Matthieu Gallien <[email protected]> Signed-off-by: Louis Chmn <[email protected]>
1 parent 24ae53b commit a293480

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/private/Files/Cache/Scanner.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
use OC\Files\Storage\Wrapper\Encryption;
1212
use OC\Files\Storage\Wrapper\Jail;
1313
use OC\Hooks\BasicEmitter;
14-
use OC\SystemConfig;
1514
use OCP\Files\Cache\IScanner;
1615
use OCP\Files\ForbiddenException;
1716
use OCP\Files\NotFoundException;
1817
use OCP\Files\Storage\ILockingStorage;
1918
use OCP\Files\Storage\IReliableEtagStorage;
19+
use OCP\IConfig;
2020
use OCP\IDBConnection;
2121
use OCP\Lock\ILockingProvider;
22+
use OC\Lock\DBLockingProvider;
23+
use OCP\Server;
2224
use Psr\Log\LoggerInterface;
2325

2426
/**
@@ -69,10 +71,10 @@ public function __construct(\OC\Files\Storage\Storage $storage) {
6971
$this->storage = $storage;
7072
$this->storageId = $this->storage->getId();
7173
$this->cache = $storage->getCache();
72-
/** @var SystemConfig $config */
73-
$config = \OC::$server->get(SystemConfig::class);
74-
$this->cacheActive = !$config->getValue('filesystem_cache_readonly', false);
75-
$this->useTransactions = !$config->getValue('filescanner_no_transactions', false);
74+
/** @var IConfig $config */
75+
$config = Server::get(IConfig::class);
76+
$this->cacheActive = !$config->getSystemValueBool('filesystem_cache_readonly', false);
77+
$this->useTransactions = !(Server::get(ILockingProvider::class) instanceof DBLockingProvider) && !$config->getSystemValueBool('filescanner_no_transactions', false);
7678
$this->lockingProvider = \OC::$server->get(ILockingProvider::class);
7779
$this->connection = \OC::$server->get(IDBConnection::class);
7880
}

lib/private/Files/Utils/Scanner.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
use OCP\Files\NotFoundException;
2828
use OCP\Files\Storage\IStorage;
2929
use OCP\Files\StorageNotAvailableException;
30+
use OCP\IConfig;
3031
use OCP\IDBConnection;
3132
use OCP\Lock\ILockingProvider;
3233
use OCP\Lock\LockedException;
34+
use OCP\Server;
3335
use Psr\Log\LoggerInterface;
3436

3537
/**
@@ -79,8 +81,10 @@ public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInte
7981
$this->db = $db;
8082
$this->dispatcher = $dispatcher;
8183
$this->logger = $logger;
84+
/** @var IConfig $config */
85+
$config = Server::get(IConfig::class);
8286
// when DB locking is used, no DB transactions will be used
83-
$this->useTransaction = !(\OC::$server->get(ILockingProvider::class) instanceof DBLockingProvider);
87+
$this->useTransaction = !(Server::get(ILockingProvider::class) instanceof DBLockingProvider) && !$config->getSystemValueBool('filescanner_no_transactions', false);
8488
}
8589

8690
/**

0 commit comments

Comments
 (0)