mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-12-22 13:56:30 +00:00
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 <cyphar@cyphar.com>
This commit is contained in:
parent
98ebe1868e
commit
63dc31a80a
1 changed files with 15 additions and 12 deletions
27
parse.go
27
parse.go
|
@ -72,27 +72,30 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
// parse the options
|
||||
f := strings.Fields(str)
|
||||
e.Name = filepath.Clean(f[0])
|
||||
e.Keywords = StringToKeyVals(f[1:])
|
||||
// TODO: gather keywords if using tar stream
|
||||
var isDir bool
|
||||
for _, kv := range e.Keywords {
|
||||
if kv.Keyword() == "type" {
|
||||
isDir = kv.Value() == "dir"
|
||||
}
|
||||
}
|
||||
if strings.Contains(e.Name, "/") {
|
||||
e.Type = FullType
|
||||
} else {
|
||||
e.Type = RelativeType
|
||||
}
|
||||
e.Keywords = StringToKeyVals(f[1:])
|
||||
// TODO: gather keywords if using tar stream
|
||||
e.Parent = creator.curDir
|
||||
for i := range e.Keywords {
|
||||
kv := KeyVal(e.Keywords[i])
|
||||
if kv.Keyword() == "type" {
|
||||
if kv.Value() == "dir" {
|
||||
creator.curDir = &e
|
||||
} else {
|
||||
creator.curEnt = &e
|
||||
}
|
||||
e.Parent = creator.curDir
|
||||
if isDir {
|
||||
creator.curDir = &e
|
||||
}
|
||||
}
|
||||
if !isDir {
|
||||
creator.curEnt = &e
|
||||
}
|
||||
e.Set = creator.curSet
|
||||
default:
|
||||
// TODO(vbatts) log a warning?
|
||||
|
|
Loading…
Reference in a new issue