*: 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
22
keywords.go
22
keywords.go
|
@ -59,6 +59,11 @@ func (kv KeyVal) Value() string {
|
|||
return strings.SplitN(strings.TrimSpace(string(kv)), "=", 2)[1]
|
||||
}
|
||||
|
||||
// ChangeValue changes the value of a KeyVal
|
||||
func (kv KeyVal) ChangeValue(newval string) string {
|
||||
return fmt.Sprintf("%s=%s", kv.Keyword(), newval)
|
||||
}
|
||||
|
||||
// keywordSelector takes an array of "keyword=value" and filters out that only the set of words
|
||||
func keywordSelector(keyval, words []string) []string {
|
||||
retList := []string{}
|
||||
|
@ -129,6 +134,17 @@ var (
|
|||
"nlink",
|
||||
"time",
|
||||
}
|
||||
// DefaultTarKeywords has keywords that should be used when creating a manifest from
|
||||
// an archive. Currently, evaluating the # of hardlinks has not been implemented yet
|
||||
DefaultTarKeywords = []string{
|
||||
"size",
|
||||
"type",
|
||||
"uid",
|
||||
"gid",
|
||||
"mode",
|
||||
"link",
|
||||
"tar_time",
|
||||
}
|
||||
// SetKeywords is the default set of keywords calculated for a `/set` SpecialType
|
||||
SetKeywords = []string{
|
||||
"uid",
|
||||
|
@ -213,11 +229,7 @@ var (
|
|||
}
|
||||
}
|
||||
tartimeKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
|
||||
t := info.ModTime().Unix()
|
||||
if t == 0 {
|
||||
return "tar_time=0.000000000", nil
|
||||
}
|
||||
return fmt.Sprintf("tar_time=%d.000000000", t), nil
|
||||
return fmt.Sprintf("tar_time=%d.000000000", info.ModTime().Unix()), nil
|
||||
}
|
||||
timeKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
|
||||
t := info.ModTime().UnixNano()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue