mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-03 14:28:28 +00:00
*: have gomtree always evaluate tar_time if it is present
if the keyword "tar_time" is present when evaluating an Entry, gomtree should use the tar_time when evaluating the "time" keyword as well. This commit also adds a test that makes sure "tar_time" wins against "time" if both are present. Some minor clean-ups as well, such as checking if KeywordFunc[keyword] actually retrieves a function. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
bc6f3bf902
commit
656e577ecc
7 changed files with 106 additions and 25 deletions
18
walk.go
18
walk.go
|
@ -80,7 +80,11 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
if str, err := KeywordFuncs[keyword](path, info, r); err == nil && str != "" {
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
}
|
||||
if str, err := keywordFunc(path, info, r); err == nil && str != "" {
|
||||
e.Keywords = append(e.Keywords, str)
|
||||
} else if err != nil {
|
||||
return err
|
||||
|
@ -107,7 +111,11 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
str, err := KeywordFuncs[keyword](path, info, r)
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
}
|
||||
str, err := keywordFunc(path, info, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -158,7 +166,11 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
str, err := KeywordFuncs[keyword](path, info, r)
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
}
|
||||
str, err := keywordFunc(path, info, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue