mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-03 22:28:29 +00:00
keyword: unify keyword synonyms
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
627c6e9ddd
commit
5d26726bb1
6 changed files with 124 additions and 3 deletions
27
keywords.go
27
keywords.go
|
@ -251,6 +251,31 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// KeywordSynonym returns the canonical name for keywords that have synonyms,
|
||||
// and just returns the name provided if there is no synonym. In this way it
|
||||
// ought to be safe to wrap any keyword name.
|
||||
func KeywordSynonym(name string) string {
|
||||
switch name {
|
||||
case "md5":
|
||||
return "md5digest"
|
||||
case "rmd160":
|
||||
return "ripemd160digest"
|
||||
case "rmd160digest":
|
||||
return "ripemd160digest"
|
||||
case "sha1":
|
||||
return "sha1digest"
|
||||
case "sha256":
|
||||
return "sha256digest"
|
||||
case "sha384":
|
||||
return "sha384digest"
|
||||
case "sha512":
|
||||
return "sha512digest"
|
||||
case "xattrs":
|
||||
return "xattr"
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
var (
|
||||
modeKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
|
||||
permissions := info.Mode().Perm()
|
||||
|
@ -292,7 +317,7 @@ var (
|
|||
if _, err := io.Copy(h, r); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%s=%x", name, h.Sum(nil)), nil
|
||||
return fmt.Sprintf("%s=%x", KeywordSynonym(name), h.Sum(nil)), nil
|
||||
}
|
||||
}
|
||||
tartimeKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue