Merge pull request #12420 from owncloud/sqlite-wal-2

adding new config parameter for sqlite to specify the journal mode
This commit is contained in:
Morris Jobke 2014-11-26 00:47:22 +01:00
commit e9696a8c9a
5 changed files with 36 additions and 21 deletions

View File

@ -133,6 +133,12 @@ $CONFIG = array(
PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem', PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem',
), ),
/**
* sqlite3 journal mode can be specified using this config parameter - can be 'WAL' or 'DELETE'
* see for more details https://www.sqlite.org/wal.html
*/
'sqlite.journal_mode' => 'DELETE',
/** /**
* Indicates whether the ownCloud instance was installed successfully; ``true`` * Indicates whether the ownCloud instance was installed successfully; ``true``
* indicates a successful installation, and ``false`` indicates an unsuccessful * indicates a successful installation, and ``false`` indicates an unsuccessful

View File

@ -90,7 +90,8 @@ class ConnectionFactory {
$eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit); $eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit);
break; break;
case 'sqlite3': case 'sqlite3':
$eventManager->addEventSubscriber(new SQLiteSessionInit); $journalMode = $additionalConnectionParams['sqlite.journal_mode'];
$eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode));
break; break;
} }
$connection = \Doctrine\DBAL\DriverManager::getConnection( $connection = \Doctrine\DBAL\DriverManager::getConnection(
@ -153,6 +154,7 @@ class ConnectionFactory {
} }
$connectionParams['tablePrefix'] = $config->getSystemValue('dbtableprefix', 'oc_'); $connectionParams['tablePrefix'] = $config->getSystemValue('dbtableprefix', 'oc_');
$connectionParams['sqlite.journal_mode'] = $config->getSystemValue('sqlite.journal_mode', 'WAL');
//additional driver options, eg. for mysql ssl //additional driver options, eg. for mysql ssl
$driverOptions = $config->getSystemValue('dbdriveroptions', null); $driverOptions = $config->getSystemValue('dbdriveroptions', null);

View File

@ -18,13 +18,20 @@ class SQLiteSessionInit implements EventSubscriber {
*/ */
private $caseSensitiveLike; private $caseSensitiveLike;
/**
* @var string
*/
private $journalMode;
/** /**
* Configure case sensitive like for each connection * Configure case sensitive like for each connection
* *
* @param bool $caseSensitiveLike * @param bool $caseSensitiveLike
* @param string $journalMode
*/ */
public function __construct($caseSensitiveLike = true) { public function __construct($caseSensitiveLike, $journalMode) {
$this->caseSensitiveLike = $caseSensitiveLike; $this->caseSensitiveLike = $caseSensitiveLike;
$this->journalMode = $journalMode;
} }
/** /**
@ -34,6 +41,7 @@ class SQLiteSessionInit implements EventSubscriber {
public function postConnect(ConnectionEventArgs $args) { public function postConnect(ConnectionEventArgs $args) {
$sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false';
$args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive);
$args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode);
} }
public function getSubscribedEvents() { public function getSubscribedEvents() {

View File

@ -27,7 +27,7 @@ class TempManager extends \Test\TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->baseDir = get_temp_dir() . '/oc_tmp_test'; $this->baseDir = get_temp_dir() . $this->getUniqueID('/oc_tmp_test');
if (!is_dir($this->baseDir)) { if (!is_dir($this->baseDir)) {
mkdir($this->baseDir); mkdir($this->baseDir);
} }
@ -39,7 +39,7 @@ class TempManager extends \Test\TestCase {
} }
/** /**
* @param \Psr\Log\LoggerInterface $logger * @param \OCP\ILogger $logger
* @return \OC\TempManager * @return \OC\TempManager
*/ */
protected function getManager($logger = null) { protected function getManager($logger = null) {

View File

@ -1,22 +1,21 @@
<?php <?php
$CONFIG = array ( $CONFIG = array (
"appstoreenabled" => false, "appstoreenabled" => false,
'apps_paths' => 'apps_paths' =>
array ( array (
0 => 0 =>
array ( array (
'path' => OC::$SERVERROOT.'/apps', 'path' => OC::$SERVERROOT.'/apps',
'url' => '/apps', 'url' => '/apps',
'writable' => true, 'writable' => true,
), ),
1 => 1 =>
array ( array (
'path' => OC::$SERVERROOT.'/apps2', 'path' => OC::$SERVERROOT.'/apps2',
'url' => '/apps2', 'url' => '/apps2',
'writable' => false, 'writable' => false,
) )
), ),
); );
if(substr(strtolower(PHP_OS), 0, 3) == "win") { if(substr(strtolower(PHP_OS), 0, 3) == "win") {