Merge pull request #21072 from owncloud/db-lock-ttl

Remove all locks after ttl from the db
This commit is contained in:
Thomas Müller 2015-12-10 13:51:18 +01:00
commit df15d54db6
2 changed files with 4 additions and 10 deletions

View File

@ -233,10 +233,10 @@ class DBLockingProvider extends AbstractLockingProvider {
/**
* cleanup empty locks
*/
public function cleanEmptyLocks() {
public function cleanExpiredLocks() {
$expire = $this->timeFactory->getTime();
$this->connection->executeUpdate(
'DELETE FROM `*PREFIX*file_locks` WHERE `lock` = 0 AND `ttl` < ?',
'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
[$expire]
);
}
@ -260,7 +260,7 @@ class DBLockingProvider extends AbstractLockingProvider {
public function __destruct() {
try {
$this->cleanEmptyLocks();
$this->cleanExpiredLocks();
} catch (\Exception $e) {
// If the table is missing, the clean up was successful
if ($this->connection->tableExists('file_locks')) {

View File

@ -85,13 +85,7 @@ class DBLockingProvider extends LockingProvider {
$this->assertEquals(3, $this->getLockEntryCount());
$this->instance->cleanEmptyLocks();
$this->assertEquals(3, $this->getLockEntryCount());
$this->instance->releaseAll();
$this->instance->cleanEmptyLocks();
$this->instance->cleanExpiredLocks();
$this->assertEquals(2, $this->getLockEntryCount());
}