Filter uncached mounts
This commit is contained in:
parent
cf6ee1c866
commit
f986fb99f2
|
@ -55,14 +55,22 @@ class UserMountCache implements IUserMountCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerMounts(IUser $user, array $mounts) {
|
public function registerMounts(IUser $user, array $mounts) {
|
||||||
|
$mounts = array_filter($mounts, function (IMountPoint $mount) {
|
||||||
|
return $mount->getStorage()->getCache();
|
||||||
|
});
|
||||||
$mounts = array_values($mounts);
|
$mounts = array_values($mounts);
|
||||||
/** @var ICachedMountInfo[] $newMounts */
|
/** @var ICachedMountInfo[] $newMounts */
|
||||||
$newMounts = array_map(function (IMountPoint $mount) use ($user) {
|
$newMounts = array_map(function (IMountPoint $mount) use ($user) {
|
||||||
$storage = $mount->getStorage();
|
$storage = $mount->getStorage();
|
||||||
$rootId = (int)$storage->getCache()->getId('');
|
$rootId = (int)$storage->getCache()->getId('');
|
||||||
$storageId = (int)$storage->getStorageCache()->getNumericId();
|
$storageId = (int)$storage->getStorageCache()->getNumericId();
|
||||||
return new CachedMountInfo($user, $storageId, $rootId, $mount->getMountPoint());
|
if ($rootId === -1) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new CachedMountInfo($user, $storageId, $rootId, $mount->getMountPoint());
|
||||||
|
}
|
||||||
}, $mounts);
|
}, $mounts);
|
||||||
|
$newMounts = array_values(array_filter($newMounts));
|
||||||
$cachedMounts = $this->getMountsForUser($user);
|
$cachedMounts = $this->getMountsForUser($user);
|
||||||
|
|
||||||
$mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) {
|
$mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) {
|
||||||
|
@ -122,17 +130,14 @@ class UserMountCache implements IUserMountCache {
|
||||||
* @return ICachedMountInfo[]
|
* @return ICachedMountInfo[]
|
||||||
*/
|
*/
|
||||||
public function getMountsForUser(IUser $user) {
|
public function getMountsForUser(IUser $user) {
|
||||||
if (!isset($this->mountsForUsers[$user->getUID()])) {
|
$builder = $this->connection->getQueryBuilder();
|
||||||
$builder = $this->connection->getQueryBuilder();
|
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point')
|
||||||
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point')
|
->from('mounts')
|
||||||
->from('mounts')
|
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
|
||||||
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
|
|
||||||
|
|
||||||
$rows = $query->execute()->fetchAll();
|
$rows = $query->execute()->fetchAll();
|
||||||
|
|
||||||
$this->mountsForUsers[$user->getUID()] = array_map([$this, 'dbRowToMountInfo'], $rows);
|
return array_map([$this, 'dbRowToMountInfo'], $rows);
|
||||||
}
|
|
||||||
return $this->mountsForUsers[$user->getUID()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue