summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-07-16 12:55:28 +0200
committerRobin Appelman <icewind@owncloud.com>2015-08-03 14:13:36 +0200
commit96a9d171b3fc31a6ad1ed89dca987765ed1ce721 (patch)
treea51669e20e585a0347ad4cf018b57c3cebd31ad5
parent86acd535c243569fda7c1a2957073509c7e94f89 (diff)
downloadnextcloud-server-96a9d171b3fc31a6ad1ed89dca987765ed1ce721.tar.gz
nextcloud-server-96a9d171b3fc31a6ad1ed89dca987765ed1ce721.zip
Fix db schema
-rw-r--r--db_structure.xml35
-rw-r--r--lib/private/lock/abstractlockingprovider.php2
-rw-r--r--lib/private/lock/dblockingprovider.php16
-rw-r--r--lib/repair/dropoldtables.php1
-rw-r--r--tests/lib/lock/dblockingprovider.php2
5 files changed, 44 insertions, 12 deletions
diff --git a/db_structure.xml b/db_structure.xml
index 95acefcfaee..5c2b26e5f15 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -1185,11 +1185,21 @@
<!--
Table for storing high-level locking
-->
- <name>*dbprefix*locks</name>
+ <name>*dbprefix*file_locks</name>
<declaration>
<field>
+ <name>id</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <unsigned>true</unsigned>
+ <length>4</length>
+ <autoincrement>1</autoincrement>
+ </field>
+
+ <field>
<name>lock</name>
<type>integer</type>
<default>0</default>
@@ -1204,10 +1214,25 @@
<length>64</length>
</field>
+ <field>
+ <name>ttl</name>
+ <type>integer</type>
+ <notnull>true</notnull>
+ <length>4</length>
+ </field>
<index>
<primary>true</primary>
<unique>true</unique>
+ <name>lock_id_index</name>
+ <field>
+ <name>id</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+
+ <index>
+ <unique>true</unique>
<name>lock_path_index</name>
<field>
<name>path</name>
@@ -1215,6 +1240,14 @@
</field>
</index>
+ <index>
+ <name>lock_ttl_index</name>
+ <field>
+ <name>ttl</name>
+ <sorting>ascending</sorting>
+ </field>
+ </index>
+
</declaration>
</table>
diff --git a/lib/private/lock/abstractlockingprovider.php b/lib/private/lock/abstractlockingprovider.php
index 290bb77e52f..03b4912ea13 100644
--- a/lib/private/lock/abstractlockingprovider.php
+++ b/lib/private/lock/abstractlockingprovider.php
@@ -1,8 +1,6 @@
<?php
/**
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php
index 70f4539eb28..aee66bca745 100644
--- a/lib/private/lock/dblockingprovider.php
+++ b/lib/private/lock/dblockingprovider.php
@@ -38,7 +38,7 @@ class DBLockingProvider extends AbstractLockingProvider {
}
protected function initLockField($path) {
- $this->connection->insertIfNotExist('*PREFIX*locks', ['path' => $path, 'lock' => 0], ['path']);
+ $this->connection->insertIfNotExist('*PREFIX*file_locks', ['path' => $path, 'lock' => 0], ['path']);
}
/**
@@ -47,7 +47,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @return bool
*/
public function isLocked($path, $type) {
- $query = $this->connection->prepare('SELECT `lock` from `*PREFIX*locks` WHERE `path` = ?');
+ $query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `path` = ?');
$query->execute([$path]);
$lockValue = (int)$query->fetchColumn();
if ($type === self::LOCK_SHARED) {
@@ -68,12 +68,12 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = `lock` + 1 WHERE `path` = ? AND `lock` >= 0',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1 WHERE `path` = ? AND `lock` >= 0',
[$path]
);
} else {
$result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = -1 WHERE `path` = ? AND `lock` = 0',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = -1 WHERE `path` = ? AND `lock` = 0',
[$path]
);
}
@@ -91,12 +91,12 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = `lock` - 1 WHERE `path` = ? AND `lock` > 0',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `path` = ? AND `lock` > 0',
[$path]
);
} else {
$this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = 0 WHERE `path` = ? AND `lock` = -1',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `path` = ? AND `lock` = -1',
[$path]
);
}
@@ -114,12 +114,12 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->initLockField($path);
if ($targetType === self::LOCK_SHARED) {
$result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = 1 WHERE `path` = ? AND `lock` = -1',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = 1 WHERE `path` = ? AND `lock` = -1',
[$path]
);
} else {
$result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*locks` SET `lock` = -1 WHERE `path` = ? AND `lock` = 1',
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = -1 WHERE `path` = ? AND `lock` = 1',
[$path]
);
}
diff --git a/lib/repair/dropoldtables.php b/lib/repair/dropoldtables.php
index 89f872e16cc..cfe0df6cb5b 100644
--- a/lib/repair/dropoldtables.php
+++ b/lib/repair/dropoldtables.php
@@ -76,6 +76,7 @@ class DropOldTables extends BasicEmitter implements RepairStep {
'calendar_share_event',
'foldersize',
'fscache',
+ 'locks',
'log',
'media_albums',
'media_artists',
diff --git a/tests/lib/lock/dblockingprovider.php b/tests/lib/lock/dblockingprovider.php
index 4229ffb9c51..4818ef1ceca 100644
--- a/tests/lib/lock/dblockingprovider.php
+++ b/tests/lib/lock/dblockingprovider.php
@@ -37,7 +37,7 @@ class DBLockingProvider extends LockingProvider {
}
public function tearDown() {
- $this->connection->executeQuery('DELETE FROM `*PREFIX*locks`');
+ $this->connection->executeQuery('DELETE FROM `*PREFIX*file_locks`');
parent::tearDown();
}
}