Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
d8964037
Unverified
Commit
d8964037
authored
Oct 22, 2019
by
Matthew Fisher
Committed by
GitHub
Oct 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6727 from bacongobbler/backport-6702
fix(sympath): walk symbolic links one once
parents
be6551c0
84892903
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
17 deletions
+35
-17
walk.go
pkg/sympath/walk.go
+2
-1
walk_test.go
pkg/sympath/walk_test.go
+33
-16
No files found.
pkg/sympath/walk.go
View file @
d8964037
...
@@ -72,9 +72,10 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
...
@@ -72,9 +72,10 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
if
info
,
err
=
os
.
Lstat
(
resolved
);
err
!=
nil
{
if
info
,
err
=
os
.
Lstat
(
resolved
);
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
symwalk
(
resolved
,
info
,
walkFn
);
err
!=
nil
&&
err
!=
filepath
.
SkipDir
{
if
err
:=
symwalk
(
path
,
info
,
walkFn
);
err
!=
nil
&&
err
!=
filepath
.
SkipDir
{
return
err
return
err
}
}
return
nil
}
}
if
err
:=
walkFn
(
path
,
info
,
nil
);
err
!=
nil
{
if
err
:=
walkFn
(
path
,
info
,
nil
);
err
!=
nil
{
...
...
pkg/sympath/walk_test.go
View file @
d8964037
...
@@ -29,34 +29,43 @@ import (
...
@@ -29,34 +29,43 @@ import (
type
Node
struct
{
type
Node
struct
{
name
string
name
string
entries
[]
*
Node
// nil if the entry is a file
entries
[]
*
Node
// nil if the entry is a file
mark
int
marks
int
expectedMarks
int
symLinkedTo
string
}
}
var
tree
=
&
Node
{
var
tree
=
&
Node
{
"testdata"
,
"testdata"
,
[]
*
Node
{
[]
*
Node
{
{
"a"
,
nil
,
0
},
{
"a"
,
nil
,
0
,
1
,
""
},
{
"b"
,
[]
*
Node
{},
0
},
{
"b"
,
[]
*
Node
{},
0
,
1
,
""
},
{
"c"
,
nil
,
0
},
{
"c"
,
nil
,
0
,
2
,
""
},
{
"d"
,
nil
,
0
,
0
,
"c"
},
{
{
"
d
"
,
"
e
"
,
[]
*
Node
{
[]
*
Node
{
{
"x"
,
nil
,
0
},
{
"x"
,
nil
,
0
,
1
,
""
},
{
"y"
,
[]
*
Node
{},
0
},
{
"y"
,
[]
*
Node
{},
0
,
1
,
""
},
{
{
"z"
,
"z"
,
[]
*
Node
{
[]
*
Node
{
{
"u"
,
nil
,
0
},
{
"u"
,
nil
,
0
,
1
,
""
},
{
"v"
,
nil
,
0
},
{
"v"
,
nil
,
0
,
1
,
""
},
{
"w"
,
nil
,
0
},
{
"w"
,
nil
,
0
,
1
,
""
},
},
},
0
,
0
,
1
,
""
,
},
},
},
},
0
,
0
,
1
,
""
,
},
},
},
},
0
,
0
,
1
,
""
,
}
}
func
walkTree
(
n
*
Node
,
path
string
,
f
func
(
path
string
,
n
*
Node
))
{
func
walkTree
(
n
*
Node
,
path
string
,
f
func
(
path
string
,
n
*
Node
))
{
...
@@ -69,24 +78,32 @@ func walkTree(n *Node, path string, f func(path string, n *Node)) {
...
@@ -69,24 +78,32 @@ func walkTree(n *Node, path string, f func(path string, n *Node)) {
func
makeTree
(
t
*
testing
.
T
)
{
func
makeTree
(
t
*
testing
.
T
)
{
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
if
n
.
entries
==
nil
{
if
n
.
entries
==
nil
{
if
n
.
symLinkedTo
!=
""
{
if
err
:=
os
.
Symlink
(
n
.
symLinkedTo
,
path
);
err
!=
nil
{
t
.
Fatalf
(
"makeTree: %v"
,
err
)
}
}
else
{
fd
,
err
:=
os
.
Create
(
path
)
fd
,
err
:=
os
.
Create
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"makeTree: %v"
,
err
)
t
.
Fatal
f
(
"makeTree: %v"
,
err
)
return
return
}
}
fd
.
Close
()
fd
.
Close
()
}
}
else
{
}
else
{
os
.
Mkdir
(
path
,
0770
)
if
err
:=
os
.
Mkdir
(
path
,
0770
);
err
!=
nil
{
t
.
Fatalf
(
"makeTree: %v"
,
err
)
}
}
}
})
})
}
}
func
checkMarks
(
t
*
testing
.
T
,
report
bool
)
{
func
checkMarks
(
t
*
testing
.
T
,
report
bool
)
{
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
if
n
.
mark
!=
1
&&
report
{
if
n
.
mark
s
!=
n
.
expectedMarks
&&
report
{
t
.
Errorf
(
"node %s mark = %d; expected
1"
,
path
,
n
.
mark
)
t
.
Errorf
(
"node %s mark = %d; expected
%d"
,
path
,
n
.
marks
,
n
.
expectedMarks
)
}
}
n
.
mark
=
0
n
.
mark
s
=
0
})
})
}
}
...
@@ -104,7 +121,7 @@ func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
...
@@ -104,7 +121,7 @@ func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
name
:=
info
.
Name
()
name
:=
info
.
Name
()
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
walkTree
(
tree
,
tree
.
name
,
func
(
path
string
,
n
*
Node
)
{
if
n
.
name
==
name
{
if
n
.
name
==
name
{
n
.
mark
++
n
.
mark
s
++
}
}
})
})
return
nil
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment