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) {
|
||||
$mounts = array_filter($mounts, function (IMountPoint $mount) {
|
||||
return $mount->getStorage()->getCache();
|
||||
});
|
||||
$mounts = array_values($mounts);
|
||||
/** @var ICachedMountInfo[] $newMounts */
|
||||
$newMounts = array_map(function (IMountPoint $mount) use ($user) {
|
||||
$storage = $mount->getStorage();
|
||||
$rootId = (int)$storage->getCache()->getId('');
|
||||
$storageId = (int)$storage->getStorageCache()->getNumericId();
|
||||
if ($rootId === -1) {
|
||||
return null;
|
||||
} else {
|
||||
return new CachedMountInfo($user, $storageId, $rootId, $mount->getMountPoint());
|
||||
}
|
||||
}, $mounts);
|
||||
$newMounts = array_values(array_filter($newMounts));
|
||||
$cachedMounts = $this->getMountsForUser($user);
|
||||
|
||||
$mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) {
|
||||
|
@ -122,7 +130,6 @@ class UserMountCache implements IUserMountCache {
|
|||
* @return ICachedMountInfo[]
|
||||
*/
|
||||
public function getMountsForUser(IUser $user) {
|
||||
if (!isset($this->mountsForUsers[$user->getUID()])) {
|
||||
$builder = $this->connection->getQueryBuilder();
|
||||
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point')
|
||||
->from('mounts')
|
||||
|
@ -130,9 +137,7 @@ class UserMountCache implements IUserMountCache {
|
|||
|
||||
$rows = $query->execute()->fetchAll();
|
||||
|
||||
$this->mountsForUsers[$user->getUID()] = array_map([$this, 'dbRowToMountInfo'], $rows);
|
||||
}
|
||||
return $this->mountsForUsers[$user->getUID()];
|
||||
return array_map([$this, 'dbRowToMountInfo'], $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue