diff --git a/ui/fixtures/cmd.basic.json b/ui/fixtures/cmd.basic.json index f6caaeb..c3a6106 100644 --- a/ui/fixtures/cmd.basic.json +++ b/ui/fixtures/cmd.basic.json @@ -67,6 +67,19 @@ "cmd": [ "list", "newfile.txt" ], "stdout_re": "dc:creator:\tJohn-Mark Gurney\nhashes:\tsha512:90f8342520f0ac57fb5a779f5d331c2fa87aa40f8799940257f9ba619940951e67143a8d746535ed0284924b2b7bc1478f095198800ba96d01847d7b56ca465c\nsig:\t.*\ntag:\t\n" }, +{ + "title": "add duplicate ms:tag's", + "cmd": [ "modify", "+ms:tag=foo", "+ms:tag=foo", "newfile.txt" ] +}, +{ + "title": "but dup tags are not dup'd", + "cmd": [ "list", "newfile.txt" ], + "stdout_re": "dc:creator:\tJohn-Mark Gurney\nhashes:\tsha512:90f8342520f0ac57fb5a779f5d331c2fa87aa40f8799940257f9ba619940951e67143a8d746535ed0284924b2b7bc1478f095198800ba96d01847d7b56ca465c\nms:tag:\tfoo\nsig:\t.*\ntag:\t\n" +}, +{ + "title": "drop ms:tag", + "cmd": [ "modify", "-ms:tag=foo", "newfile.txt" ] +}, { "title": "add tag", "cmd": [ "modify", "+dc:creator=Another user", "newfile.txt" ] diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index 2339f6a..7ce9392 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -253,6 +253,8 @@ class MDBase(object): class MetaData(MDBase): _type = 'metadata' + _uniq_properties = set([ 'ms:tag' ]) + class Identity(MDBase): _type = 'identity' @@ -873,8 +875,14 @@ def cmd_modify(options): obj[key].remove(v) # add tags + uniqify = set() for k, v in adds: obj.setdefault(k, []).append(v) + if k in j._uniq_properties: + uniqify.add(k) + + for k in uniqify: + obj[k] = list(set(obj[k])) #print('a:', repr(obj), file=_real_stderr) del obj['modified']