Compare commits

...

1 Commits

Author SHA1 Message Date
Louis Chmn
f6fe536467 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 <matthieu.gallien@nextcloud.com>
Signed-off-by: Louis Chmn <louis@chmn.me>
2025-11-12 12:31:32 +01:00
2 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ use OCP\Files\Storage\IReliableEtagStorage;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OC\Lock\DBLockingProvider;
use OCP\Server;
use Psr\Log\LoggerInterface;
@@ -70,9 +71,10 @@ class Scanner extends BasicEmitter implements IScanner {
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
/** @var IConfig $config */
$config = Server::get(IConfig::class);
$this->cacheActive = !$config->getSystemValueBool('filesystem_cache_readonly', false);
$this->useTransactions = !$config->getSystemValueBool('filescanner_no_transactions', false);
$this->useTransactions = !(Server::get(ILockingProvider::class) instanceof DBLockingProvider) && !$config->getSystemValueBool('filescanner_no_transactions', false);
$this->lockingProvider = Server::get(ILockingProvider::class);
$this->connection = Server::get(IDBConnection::class);
}

View File

@@ -27,9 +27,11 @@ use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -79,8 +81,10 @@ class Scanner extends PublicEmitter {
$this->db = $db;
$this->dispatcher = $dispatcher;
$this->logger = $logger;
/** @var IConfig $config */
$config = Server::get(IConfig::class);
// when DB locking is used, no DB transactions will be used
$this->useTransaction = !(\OC::$server->get(ILockingProvider::class) instanceof DBLockingProvider);
$this->useTransaction = !(Server::get(ILockingProvider::class) instanceof DBLockingProvider) && !$config->getSystemValueBool('filescanner_no_transactions', false);
}
/**