*: xattr can Update()
This is a gnarly patchset that has been mashed together. It uncovered that some aspects of Check were never really working correctly for `xattr` keywords, but also the `Update()` had been left undone for a while. This includes some API changes around the `Keyword` and `KeyVal` types. Also I would like to update the signature for the `UpdateKeywordFunc` to just accept a `KeyVal` as an argugment, rather than a keyword AND the value. with this context there would be no need to guess on the value of what's passed to the xattr update function of whether it needs or already is base64 encoded. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
fb4ec19981
commit
ed464af779
19 changed files with 398 additions and 258 deletions
38
walk.go
38
walk.go
|
@ -101,15 +101,19 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
if str, err := creator.fs.KeywordFunc(keywordFunc)(path, info, r); err == nil && str != "" {
|
||||
e.Keywords = append(e.Keywords, str)
|
||||
} else if err != nil {
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, kv := range kvs {
|
||||
if kv != "" {
|
||||
e.Keywords = append(e.Keywords, kv)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
if err != nil {
|
||||
|
@ -132,16 +136,18 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
str, err := creator.fs.KeywordFunc(keywordFunc)(path, info, r)
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if str != "" {
|
||||
klist = append(klist, str)
|
||||
for _, kv := range kvs {
|
||||
if kv != "" {
|
||||
klist = append(klist, kv)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
|
@ -190,16 +196,18 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
defer fh.Close()
|
||||
r = fh
|
||||
}
|
||||
keywordFunc, ok := KeywordFuncs[keyword]
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword, path)
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
str, err := creator.fs.KeywordFunc(keywordFunc)(path, info, r)
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if str != "" && !inKeyValSlice(str, creator.curSet.Keywords) {
|
||||
e.Keywords = append(e.Keywords, str)
|
||||
for _, kv := range kvs {
|
||||
if kv != "" && !inKeyValSlice(kv, creator.curSet.Keywords) {
|
||||
e.Keywords = append(e.Keywords, kv)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue