aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bounded_tree/bounded_tree.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-12 21:58:37 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-12 21:58:37 -0700
commitb18f21cce178b60531086f164d24e832a7b6eb86 (patch)
tree328a7050a256977bef47edd9e45bff7fb5cb1eb6 /weed/util/bounded_tree/bounded_tree.go
parentf022aff289d509e93a93a0e8386693876d1be240 (diff)
downloadseaweedfs-b18f21cce178b60531086f164d24e832a7b6eb86.tar.xz
seaweedfs-b18f21cce178b60531086f164d24e832a7b6eb86.zip
mount: fix bound tree with filer.path
fix https://github.com/chrislusf/seaweedfs/issues/1528
Diffstat (limited to 'weed/util/bounded_tree/bounded_tree.go')
-rw-r--r--weed/util/bounded_tree/bounded_tree.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/weed/util/bounded_tree/bounded_tree.go b/weed/util/bounded_tree/bounded_tree.go
index 0e023c0d1..0182aeba1 100644
--- a/weed/util/bounded_tree/bounded_tree.go
+++ b/weed/util/bounded_tree/bounded_tree.go
@@ -16,13 +16,15 @@ type Node struct {
type BoundedTree struct {
root *Node
sync.RWMutex
+ baseDir util.FullPath
}
-func NewBoundedTree() *BoundedTree {
+func NewBoundedTree(baseDir util.FullPath) *BoundedTree {
return &BoundedTree{
root: &Node{
Name: "/",
},
+ baseDir: baseDir,
}
}
@@ -39,9 +41,12 @@ func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) {
if t.root == nil {
return
}
+ if t.baseDir != "/" {
+ p = p[len(t.baseDir):]
+ }
components := p.Split()
// fmt.Printf("components %v %d\n", components, len(components))
- if canDelete := t.ensureVisited(t.root, util.FullPath("/"), components, 0, visitFn); canDelete {
+ if canDelete := t.ensureVisited(t.root, t.baseDir, components, 0, visitFn); canDelete {
t.root = nil
}
}
@@ -60,7 +65,12 @@ func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, componen
} else {
// fmt.Printf("ensure %v\n", currentPath)
- children, err := visitFn(currentPath)
+ filerPath := currentPath
+ if t.baseDir != "/" {
+ filerPath = t.baseDir + filerPath
+ }
+
+ children, err := visitFn(filerPath)
if err != nil {
glog.V(0).Infof("failed to visit %s: %v", currentPath, err)
return