Added config switch for file locking
This commit is contained in:
parent
c72ea9f7d7
commit
2f4f468399
|
@ -1026,6 +1026,19 @@ $CONFIG = array(
|
|||
*/
|
||||
'max_filesize_animated_gifs_public_sharing' => 10,
|
||||
|
||||
|
||||
/**
|
||||
* Enables the EXPERIMENTAL file locking.
|
||||
* This is disabled by default as it is experimental.
|
||||
*
|
||||
* Prevents concurrent processes to access the same files
|
||||
* at the same time. Can help prevent side effects that would
|
||||
* be caused by concurrent operations.
|
||||
*
|
||||
* WARNING: EXPERIMENTAL
|
||||
*/
|
||||
'filelocking.enabled' => false,
|
||||
|
||||
/**
|
||||
* This entry is just here to show a warning in case somebody copied the sample
|
||||
* configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION!
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Vincent Petry <pvince81@owncloud.com>
|
||||
*
|
||||
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Lock;
|
||||
|
||||
use OCP\Lock\ILockingProvider;
|
||||
|
||||
/**
|
||||
* Locking provider that does nothing.
|
||||
*
|
||||
* To be used when locking is disabled.
|
||||
*/
|
||||
class NoopLockingProvider implements ILockingProvider {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLocked($path, $type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function acquireLock($path, $type) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function releaseLock($path, $type) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* release all lock acquired by this instance
|
||||
*/
|
||||
public function releaseAll() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ use OC\Diagnostics\NullQueryLogger;
|
|||
use OC\Diagnostics\EventLogger;
|
||||
use OC\Diagnostics\QueryLogger;
|
||||
use OC\Lock\MemcacheLockingProvider;
|
||||
use OC\Lock\NoopLockingProvider;
|
||||
use OC\Mail\Mailer;
|
||||
use OC\Memcache\ArrayCache;
|
||||
use OC\Http\Client\ClientService;
|
||||
|
@ -422,11 +423,15 @@ class Server extends SimpleContainer implements IServerContainer {
|
|||
);
|
||||
});
|
||||
$this->registerService('LockingProvider', function (Server $c) {
|
||||
/** @var \OC\Memcache\Factory $memcacheFactory */
|
||||
$memcacheFactory = $c->getMemCacheFactory();
|
||||
return new MemcacheLockingProvider(
|
||||
$memcacheFactory->createDistributed('lock')
|
||||
);
|
||||
if ($c->getConfig()->getSystemValue('filelocking.enabled', false)) {
|
||||
/** @var \OC\Memcache\Factory $memcacheFactory */
|
||||
$memcacheFactory = $c->getMemCacheFactory();
|
||||
$memcache = $memcacheFactory->createDistributed('lock');
|
||||
if (!($memcache instanceof \OC\Memcache\Null)) {
|
||||
return new MemcacheLockingProvider($memcache);
|
||||
}
|
||||
}
|
||||
return new NoopLockingProvider();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue