/**
  * @param string $path
  * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  */
 public function releaseLock($path, $type)
 {
     // we DONT keep shared locks till the end of the request
     if ($type === self::LOCK_SHARED) {
         $this->db->executeUpdate('UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = 1', [$path]);
     }
     parent::releaseLock($path, $type);
 }
Exemplo n.º 2
0
 public function testCleanEmptyLocks()
 {
     $this->currentTime = 100;
     $this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
     $this->instance->acquireLock('asd', ILockingProvider::LOCK_EXCLUSIVE);
     $this->currentTime = 200;
     $this->instance->acquireLock('bar', ILockingProvider::LOCK_EXCLUSIVE);
     $this->instance->changeLock('asd', ILockingProvider::LOCK_SHARED);
     $this->currentTime = 150 + \OC\Lock\DBLockingProvider::TTL;
     $this->assertEquals(3, $this->getLockEntryCount());
     $this->instance->cleanEmptyLocks();
     $this->assertEquals(3, $this->getLockEntryCount());
     $this->instance->releaseAll();
     $this->instance->cleanEmptyLocks();
     $this->assertEquals(2, $this->getLockEntryCount());
 }