Ejemplo n.º 1
0
        public async Task <IndexRoot> Integrate(ICollection <VirtualFile> files)
        {
            Utils.Log($"Integrating {files.Count} files");
            var allFiles = AllFiles.Concat(files)
                           .OrderByDescending(f => f.LastModified)
                           .GroupBy(f => f.FullPath).Select(g => g.Last())
                           .ToList();

            var byFullPath = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                      .ToDictionary(f => f.FullPath));

            var byHash = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                  .Where(f => f.Hash != Hash.Empty)
                                  .ToLookup(f => f.Hash));

            var byName = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                  .ToLookup(f => f.Name));

            var byRootPath = Task.Run(() => allFiles.ToDictionary(f => f.AbsoluteName));

            var result = new IndexRoot(allFiles,
                                       await byFullPath,
                                       await byHash,
                                       await byRootPath,
                                       await byName);

            Utils.Log($"Done integrating");
            return(result);
        }
Ejemplo n.º 2
0
        public async Task <IndexRoot> Integrate(ICollection <VirtualFile> files)
        {
            Utils.Log($"Integrating {files.Count} files");
            var allFiles = AllFiles.Concat(files).GroupBy(f => f.Name).Select(g => g.Last()).ToImmutableList();

            var byFullPath = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                      .ToImmutableDictionary(f => f.FullPath));

            var byHash = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                  .Where(f => f.Hash != null)
                                  .ToGroupedImmutableDictionary(f => f.Hash));

            var byName = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren)
                                  .ToGroupedImmutableDictionary(f => f.Name));

            var byRootPath = Task.Run(() => allFiles.ToImmutableDictionary(f => f.Name));

            var result = new IndexRoot(allFiles,
                                       await byFullPath,
                                       await byHash,
                                       await byRootPath,
                                       await byName);

            Utils.Log($"Done integrating");
            return(result);
        }