Remove the need for the transaction in the database locking backend

This commit is contained in:
Robin Appelman 2015-09-16 17:29:34 +02:00 committed by Thomas Müller
parent c9397dffea
commit 7c66328381

View file

@ -76,11 +76,10 @@ class DBLockingProvider extends AbstractLockingProvider {
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type) {
if ($this->connection->inTransaction()){
if ($this->connection->inTransaction()) {
$this->logger->warning("Trying to acquire a lock for '$path' while inside a transition");
}
$this->connection->beginTransaction();
$this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$result = $this->connection->executeUpdate(
@ -93,7 +92,6 @@ class DBLockingProvider extends AbstractLockingProvider {
[$path]
);
}
$this->connection->commit();
if ($result !== 1) {
throw new LockedException($path);
}
@ -146,17 +144,4 @@ class DBLockingProvider extends AbstractLockingProvider {
}
$this->markChange($path, $targetType);
}
/**
* cleanup empty locks
*/
public function cleanEmptyLocks() {
$this->connection->executeUpdate(
'DELETE FROM `*PREFIX*file_locks` WHERE `lock` = 0'
);
}
public function __destruct() {
$this->cleanEmptyLocks();
}
}