func writeFileTree(ctx context.Context, tree *filetree.Map, out table.Proto) error { for corpus, roots := range tree.M { for root, dirs := range roots { for path, dir := range dirs { if err := out.Put(ctx, ftsrv.DirKey(corpus, root, path), dir); err != nil { return err } } } } cr, err := tree.CorpusRoots(ctx, &ftpb.CorpusRootsRequest{}) if err != nil { return err } return out.Put(ctx, ftsrv.CorpusRootsKey, cr) }
func writeFileTree(ctx context.Context, t table.Proto, files <-chan *spb.VName) error { tree := filetree.NewMap() for f := range files { tree.AddFile(f) // TODO(schroederc): evict finished directories (based on GraphStore order) } for corpus, roots := range tree.M { for root, dirs := range roots { for path, dir := range dirs { if err := t.Put(ftsrv.DirKey(corpus, root, path), dir); err != nil { return err } } } } cr, err := tree.CorpusRoots(ctx, &ftpb.CorpusRootsRequest{}) if err != nil { return err } return t.Put(ftsrv.CorpusRootsKey, cr) }