|
@ -10,24 +10,32 @@ import ( |
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.FullPath) error { |
|
|
|
|
|
|
|
|
func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.FullPath, entryChan chan *filer.Entry) error { |
|
|
|
|
|
|
|
|
|
|
|
currentPath := dirPath |
|
|
|
|
|
|
|
|
for { |
|
|
for { |
|
|
|
|
|
|
|
|
// the directory children are already cached
|
|
|
// the directory children are already cached
|
|
|
// so no need for this and upper directories
|
|
|
// so no need for this and upper directories
|
|
|
if mc.isCachedFn(dirPath) { |
|
|
|
|
|
|
|
|
if mc.isCachedFn(currentPath) { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if err := doEnsureVisited(mc, client, dirPath); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
|
|
|
if entryChan != nil && dirPath == currentPath { |
|
|
|
|
|
if err := doEnsureVisited(mc, client, currentPath, entryChan); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if err := doEnsureVisited(mc, client, currentPath, nil); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// continue to parent directory
|
|
|
// continue to parent directory
|
|
|
if dirPath != "/" { |
|
|
|
|
|
parent, _ := dirPath.DirAndName() |
|
|
|
|
|
dirPath = util.FullPath(parent) |
|
|
|
|
|
|
|
|
if currentPath != "/" { |
|
|
|
|
|
parent, _ := currentPath.DirAndName() |
|
|
|
|
|
currentPath = util.FullPath(parent) |
|
|
} else { |
|
|
} else { |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
@ -37,7 +45,7 @@ func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.Full |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func doEnsureVisited(mc *MetaCache, client filer_pb.FilerClient, path util.FullPath) error { |
|
|
|
|
|
|
|
|
func doEnsureVisited(mc *MetaCache, client filer_pb.FilerClient, path util.FullPath, entryChan chan *filer.Entry) error { |
|
|
|
|
|
|
|
|
glog.V(4).Infof("ReadDirAllEntries %s ...", path) |
|
|
glog.V(4).Infof("ReadDirAllEntries %s ...", path) |
|
|
|
|
|
|
|
@ -51,6 +59,9 @@ func doEnsureVisited(mc *MetaCache, client filer_pb.FilerClient, path util.FullP |
|
|
glog.V(0).Infof("read %s: %v", entry.FullPath, err) |
|
|
glog.V(0).Infof("read %s: %v", entry.FullPath, err) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
if entryChan != nil { |
|
|
|
|
|
entryChan <- entry |
|
|
|
|
|
} |
|
|
return nil |
|
|
return nil |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|