summaryrefslogtreecommitdiffstats
path: root/lib/private/db
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-07-28 10:29:39 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-07-28 10:29:39 +0200
commitc87f425fe790b1f7958dd5a84a38f7dcef47c383 (patch)
treedcffc54e6637a879b1bb2ca77b6f9af6474f761d /lib/private/db
parentf2982b7a089780732bb2027ca9ba3362f1d01846 (diff)
downloadnextcloud-server-c87f425fe790b1f7958dd5a84a38f7dcef47c383.tar.gz
nextcloud-server-c87f425fe790b1f7958dd5a84a38f7dcef47c383.zip
generate copy of sqlite database file in data directory
Diffstat (limited to 'lib/private/db')
-rw-r--r--lib/private/db/mdb2schemamanager.php3
-rw-r--r--lib/private/db/sqlitemigrator.php26
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index d3e379c9417..91e590a901a 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -59,7 +59,8 @@ class MDB2SchemaManager {
public function getMigrator() {
$platform = $this->conn->getDatabasePlatform();
if ($platform instanceof SqlitePlatform) {
- return new SQLiteMigrator($this->conn);
+ $config = \OC::$server->getConfig();
+ return new SQLiteMigrator($this->conn, $config);
} else if ($platform instanceof OraclePlatform) {
return new OracleMigrator($this->conn);
} else if ($platform instanceof MySqlPlatform) {
diff --git a/lib/private/db/sqlitemigrator.php b/lib/private/db/sqlitemigrator.php
index f5f78986771..81bbcb567ea 100644
--- a/lib/private/db/sqlitemigrator.php
+++ b/lib/private/db/sqlitemigrator.php
@@ -11,6 +11,21 @@ namespace OC\DB;
use Doctrine\DBAL\DBALException;
class SQLiteMigrator extends Migrator {
+
+ /**
+ * @var \OCP\IConfig
+ */
+ private $config;
+
+ /**
+ * @param \Doctrine\DBAL\Connection $connection
+ * @param \OCP\IConfig $config
+ */
+ public function __construct(\Doctrine\DBAL\Connection $connection, \OCP\IConfig $config) {
+ parent::__construct($connection);
+ $this->config = $config;
+ }
+
/**
* @param \Doctrine\DBAL\Schema\Schema $targetSchema
* @throws \OC\DB\MigrationException
@@ -19,7 +34,7 @@ class SQLiteMigrator extends Migrator {
*/
public function checkMigrate(\Doctrine\DBAL\Schema\Schema $targetSchema) {
$dbFile = $this->connection->getDatabase();
- $tmpFile = \OC_Helper::tmpFile('.db');
+ $tmpFile = $this->buildTempDatabase();
copy($dbFile, $tmpFile);
$connectionParams = array(
@@ -37,4 +52,13 @@ class SQLiteMigrator extends Migrator {
throw new MigrationException('', $e->getMessage());
}
}
+
+ /**
+ * @return string
+ */
+ private function buildTempDatabase() {
+ $dataDir = $this->config->getSystemValue("datadirectory", \OC::$SERVERROOT . '/data');
+ $tmpFile = uniqid("oc_");
+ return "$dataDir/$tmpFile.db";
+ }
}