Fix duplicate Folders bug

This commit is contained in:
ig 2023-03-08 15:45:53 +01:00
parent 2240d3ef47
commit ee14c0844b
1 changed files with 10 additions and 6 deletions

View File

@ -89,19 +89,23 @@ public partial class Db : IDisposable
public IEnumerable<Installation> GetAllAccessibleInstallations(User user) public IEnumerable<Installation> GetAllAccessibleInstallations(User user)
{ {
var direct = GetDirectlyAccessibleInstallations(user).ToList(); var direct = GetDirectlyAccessibleInstallations(user);
var fromFolders = GetAllAccessibleFolders(user) var fromFolders = GetAllAccessibleFolders(user)
.SelectMany(GetChildInstallations) .SelectMany(GetChildInstallations);
.Except(direct);
return direct.Concat(fromFolders); return direct
.Concat(fromFolders)
.Distinct();
} }
public IEnumerable<Folder> GetAllAccessibleFolders(User user) public IEnumerable<Folder> GetAllAccessibleFolders(User user)
{ {
return GetDirectlyAccessibleFolders(user) return GetDirectlyAccessibleFolders(user)
.SelectMany(GetDescendantFolders); .SelectMany(GetDescendantFolders)
.Distinct();
// Distinct because the user might have direct access
// to a child folder of a folder he has already access to
} }