Use md5 + prefix for file locking keys in memcache

Also trim slashes from paths to make sure the locks are based on the
same paths.
This commit is contained in:
Vincent Petry 2015-05-13 12:12:39 +02:00 committed by Robin Appelman
parent 0775e9c1ca
commit 8d53dc803f
2 changed files with 5 additions and 3 deletions

View File

@ -630,7 +630,7 @@ abstract class Common implements Storage {
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, ILockingProvider $provider) {
$provider->acquireLock(md5($this->getId() . '::' . $path), $type);
$provider->acquireLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
}
/**
@ -639,6 +639,6 @@ abstract class Common implements Storage {
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, ILockingProvider $provider) {
$provider->releaseLock(md5($this->getId() . '::' . $path), $type);
$provider->releaseLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
}
}

View File

@ -1621,9 +1621,11 @@ class View {
if (!$path) {
return [];
}
$path = trim($path, '/');
$parts = explode('/', $path);
// remove the singe file
// remove the single file
array_pop($parts);
$result = array('/');
$resultPath = '';