public async Task <List <string> > GetImageSourcesForCleanAsync() { List <string> sources = new List <string>(); var imagesInDirectory = DirectoryExtensions.GetFilesWithExcludeChildDirectory(uploadDirectory, "*.*", SearchOption.AllDirectories, x => !x.StartsWith("_")).Select(Get2LastSegments).ToList(); var materialSources = await GetMaterialSourcesFromASharp(); var msgSources = await GetMessageSourcesFromASharp(); var avatarSources = await GetAvatarSources(); var allSources = new List <string>(); allSources.AddRange(materialSources); allSources.AddRange(msgSources); allSources.AddRange(avatarSources); foreach (var imagePath in imagesInDirectory) { if (!allSources.Contains(imagePath)) { sources.Add(imagePath); } } return(sources); }
public async Task <List <string> > GetImageSourcesForCleanAsync() { var imagesInDirectory = DirectoryExtensions.GetFilesWithExcludeChildDirectory(uploadDirectory, "*.*", x => !x.Contains("_")).Select(Get2LastSegments).ToList(); var allSources = await Task.Factory.ContinueWhenAll( new[] { GetMaterialSourcesFromASharpAsync(), GetCommentsSourcesFromASharpAsync(), GetAvatarSourcesAsync() }, tasks => new List <string>(tasks.SelectMany(t => t.Result))); return(new List <string>(imagesInDirectory.Where(imagePath => !allSources.Contains(imagePath)))); }