mirror of
https://github.com/nextcloud/server.git
synced 2024-08-29 17:54:44 +02:00
Remove all locks after ttl from the db
This commit is contained in:
parent
5c95939bf3
commit
e191953942
@ -235,10 +235,10 @@ class DBLockingProvider extends AbstractLockingProvider {
|
|||||||
/**
|
/**
|
||||||
* cleanup empty locks
|
* cleanup empty locks
|
||||||
*/
|
*/
|
||||||
public function cleanEmptyLocks() {
|
public function cleanExpiredLocks() {
|
||||||
$expire = $this->timeFactory->getTime();
|
$expire = $this->timeFactory->getTime();
|
||||||
$this->connection->executeUpdate(
|
$this->connection->executeUpdate(
|
||||||
'DELETE FROM `*PREFIX*file_locks` WHERE `lock` = 0 AND `ttl` < ?',
|
'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
|
||||||
[$expire]
|
[$expire]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ class DBLockingProvider extends AbstractLockingProvider {
|
|||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
try {
|
try {
|
||||||
$this->cleanEmptyLocks();
|
$this->cleanExpiredLocks();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// If the table is missing, the clean up was successful
|
// If the table is missing, the clean up was successful
|
||||||
if ($this->connection->tableExists('file_locks')) {
|
if ($this->connection->tableExists('file_locks')) {
|
||||||
|
@ -85,13 +85,7 @@ class DBLockingProvider extends LockingProvider {
|
|||||||
|
|
||||||
$this->assertEquals(3, $this->getLockEntryCount());
|
$this->assertEquals(3, $this->getLockEntryCount());
|
||||||
|
|
||||||
$this->instance->cleanEmptyLocks();
|
$this->instance->cleanExpiredLocks();
|
||||||
|
|
||||||
$this->assertEquals(3, $this->getLockEntryCount());
|
|
||||||
|
|
||||||
$this->instance->releaseAll();
|
|
||||||
|
|
||||||
$this->instance->cleanEmptyLocks();
|
|
||||||
|
|
||||||
$this->assertEquals(2, $this->getLockEntryCount());
|
$this->assertEquals(2, $this->getLockEntryCount());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user