public async Task RefreshFromFileSystem() { var foundFiles = new List <IFile>(); foundFiles.AddRange(await _search.FindFiles()); await await Task.Factory.StartNew(async() => { foreach (var file in foundFiles.Where(x => !FoundFiles.Keys.Contains(x.PathSha1))) { FoundFiles.AddOrUpdate(file.PathSha1, file, (k, v) => v = file); } await UpdateStorage(); foreach (var file in FoundFiles.Values.Where(x => x.GetFileInfo() == null)) { if (file is Nupkg nu) { await _store.DeleteFile(nu); } else if (file is Project pj) { await _store.DeleteFile(pj); } else if (file is Solution sol) { await _store.DeleteFile(sol); } } }); }
public async Task <List <IFile> > GetFiles() { var fromStorage = await _store.GetFiles(); foreach (var file in fromStorage) { FoundFiles.AddOrUpdate(file.PathSha1, file, (k, v) => v = file); } foreach (var dictItem in FoundFiles.Values) { if (!fromStorage.Any(x => x.PathSha1 == dictItem.PathSha1)) { FoundFiles.TryRemove(dictItem.PathSha1, out var deletedItem); } } if (!SearchedAlready) { await RefreshFromFileSystem(); SearchedAlready = true; } return(FoundFiles.Values.ToList()); }