You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
999 B

  1. package meta_cache
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/chrislusf/seaweedfs/weed/filer2"
  6. "github.com/chrislusf/seaweedfs/weed/glog"
  7. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  8. "github.com/chrislusf/seaweedfs/weed/util"
  9. )
  10. func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.FullPath) {
  11. mc.visitedBoundary.EnsureVisited(dirPath, func(path util.FullPath) (childDirectories []string, err error) {
  12. glog.V(2).Infof("ReadDirAllEntries %s ...", path)
  13. err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
  14. entry := filer2.FromPbEntry(string(dirPath), pbEntry)
  15. if err := mc.InsertEntry(context.Background(), entry); err != nil {
  16. glog.V(0).Infof("read %s: %v", entry.FullPath, err)
  17. return err
  18. }
  19. if entry.IsDirectory() {
  20. childDirectories = append(childDirectories, entry.Name())
  21. }
  22. return nil
  23. })
  24. if err != nil {
  25. err = fmt.Errorf("list %s: %v", dirPath, err)
  26. }
  27. return
  28. })
  29. }