Merge branch 'master' into fix-type-hint-errors-container

This commit is contained in:
Morris Jobke 2015-09-23 11:01:59 +02:00
commit 56a795ad37
3 changed files with 28 additions and 13 deletions

View file

@ -609,7 +609,9 @@ $CONFIG = array(
/**
* ownCloud uses some 3rd party PHP components to provide certain functionality.
* These components are shipped as part of the software package and reside in
* ``owncloud/3rdparty``. Use this option to configure a different location.
* ``owncloud/3rdparty``. Use this option to configure a different location.
* For example, if your location is /var/www/owncloud/foo/3rdparty, then the
* correct configuration is '3rdpartyroot' => '/var/www/owncloud/foo/',
*/
'3rdpartyroot' => '',

View file

@ -1972,4 +1972,5 @@ jQuery.fn.tipsy = function(argument) {
this.tooltip(argument);
jQuery.fn.tooltip.call(this, argument);
}
return this;
}

View file

@ -58,9 +58,17 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->timeFactory = $timeFactory;
}
protected function initLockField($path) {
/**
* Insert a file locking row if it does not exists.
*
* @param string $path
* @param int $lock
* @return int number of inserted rows
*/
protected function initLockField($path, $lock = 0) {
$expire = $this->getExpireTime();
$this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => 0, 'ttl' => $expire], ['key']);
return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']);
}
/**
@ -98,18 +106,23 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->logger->warning("Trying to acquire a lock for '$path' while inside a transition");
}
$this->initLockField($path);
$expire = $this->getExpireTime();
if ($type === self::LOCK_SHARED) {
$result = $this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
[$expire, $path]
);
$result = $this->initLockField($path,1);
if ($result <= 0) {
$result = $this->connection->executeUpdate (
'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
[$expire, $path]
);
}
} else {
$result = $this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
[$expire, $path]
);
$result = $this->initLockField($path,-1);
if ($result <= 0) {
$result = $this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
[$expire, $path]
);
}
}
if ($result !== 1) {
throw new LockedException($path);
@ -122,7 +135,6 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
public function releaseLock($path, $type) {
$this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `key` = ? AND `lock` > 0',