mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 17:00:57 -06:00
Fix 'decomposedfs meta set' value handling
Don't strip off the first two characters of the target value to set unconditionally. Also print an error if decoding hex/base64 values fails (falling back to treating the values as strings).
This commit is contained in:
committed by
Ralf Haferkamp
parent
e0ec2c1ccd
commit
046ff50f52
@@ -135,15 +135,19 @@ func setCmd(cfg *config.Config) *cli.Command {
|
||||
b64, err := base64.StdEncoding.DecodeString(v[2:])
|
||||
if err == nil {
|
||||
v = string(b64)
|
||||
} else {
|
||||
fmt.Printf("Error decoding base64 string: '%s'. Using as raw string.\n", err)
|
||||
}
|
||||
} else if strings.HasPrefix(v, "0x") {
|
||||
h, err := hex.DecodeString(v)
|
||||
h, err := hex.DecodeString(v[2:])
|
||||
if err == nil {
|
||||
v = string(h)
|
||||
} else {
|
||||
fmt.Printf("Error decoding base64 string: '%s'. Using as raw string.\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
err = backend.Set(path, c.String("attribute"), []byte(v[2:]))
|
||||
err = backend.Set(path, c.String("attribute"), []byte(v))
|
||||
if err != nil {
|
||||
fmt.Println("Error setting attribute")
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user