Skip to content

Commit 63dc31a

Browse files
committed
parse: do not allow FullType entries to affect the current directory
As per the spec[1], Full entries must not affect the current directory. Handling this incorrectly caused us issues with certain manifests (ones with mixed Relative and Full entries, which is something casync does by accident). This is a partial fix for the issues with verifying casync-mtree's output but there are a few other issues to iron out (including one within casync). [1]: https://man.netbsd.org/mtree.5 Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 98ebe18 commit 63dc31a

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

parse.go

+15-12
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,30 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
7272
break
7373
}
7474
}
75+
7576
// parse the options
7677
f := strings.Fields(str)
7778
e.Name = filepath.Clean(f[0])
79+
e.Keywords = StringToKeyVals(f[1:])
80+
// TODO: gather keywords if using tar stream
81+
var isDir bool
82+
for _, kv := range e.Keywords {
83+
if kv.Keyword() == "type" {
84+
isDir = kv.Value() == "dir"
85+
}
86+
}
7887
if strings.Contains(e.Name, "/") {
7988
e.Type = FullType
8089
} else {
8190
e.Type = RelativeType
82-
}
83-
e.Keywords = StringToKeyVals(f[1:])
84-
// TODO: gather keywords if using tar stream
85-
e.Parent = creator.curDir
86-
for i := range e.Keywords {
87-
kv := KeyVal(e.Keywords[i])
88-
if kv.Keyword() == "type" {
89-
if kv.Value() == "dir" {
90-
creator.curDir = &e
91-
} else {
92-
creator.curEnt = &e
93-
}
91+
e.Parent = creator.curDir
92+
if isDir {
93+
creator.curDir = &e
9494
}
9595
}
96+
if !isDir {
97+
creator.curEnt = &e
98+
}
9699
e.Set = creator.curSet
97100
default:
98101
// TODO(vbatts) log a warning?

0 commit comments

Comments
 (0)