Browse Source

fix two bugs, first is deleting tag that didn't exist was an error

second is auto was applying to all files if multiple were specified
on the command line resulting in all the mimetypes applied to all
the files...
main
John-Mark Gurney 8 months ago
parent
commit
71128c1767
2 changed files with 19 additions and 3 deletions
  1. +12
    -0
      ui/fixtures/cmd.auto.json
  2. +7
    -3
      ui/medashare/cli.py

+ 12
- 0
ui/fixtures/cmd.auto.json View File

@@ -27,5 +27,17 @@
"cmd": [ "list", "z.jpg" ],
"stdin": "y\n",
"stdout_re": "mimetype:\timage/jpeg"
},
{
"title": "Test auto detection of two files",
"cmd": [ "auto", "z.jpg", "test.txt" ],
"stdin": "y\ny\n",
"stdout": "Set:\n\tmimetype:\timage/jpeg\n\nApply (y/N)?\nSet:\n\tmimetype:\ttext/plain; charset=us-ascii\n\nApply (y/N)?\n"
},
{
"title": "Verify modification",
"cmd": [ "list", "z.jpg", "test.txt" ],
"stdin": "y\n",
"stdout_re": "hashes:.*\nmimetype:\timage/jpeg.*\nsig:.*\nhashes:.*\nmimetype:\ttext/plain.*\nsig:.*\n"
}
]

+ 7
- 3
ui/medashare/cli.py View File

@@ -1030,7 +1030,10 @@ def cmd_modify(options, persona, objstr, cache):
try:
key, v = k
except ValueError:
del obj[k[0]]
try:
del obj[k[0]]
except KeyError:
pass
else:
obj[key].remove(v)

@@ -1372,7 +1375,7 @@ def cmd_dump(options, persona, objstr, cache):
print(i.encode('json'))

def cmd_auto(options):
for i in options.files:
for i in options.files[:]:
mf = detect_from_filename(i)

primary = mf[0].split('/', 1)[0]
@@ -1388,7 +1391,8 @@ def cmd_auto(options):
inp = sys.stdin.readline()

if inp.strip().lower() in ('y', 'yes'):
options.modtagvalues = [ '+mimetype=%s' % mt ]
options.modtagvalues = [ '-mimetype', '+mimetype=%s' % mt ]
options.files = [ i ]
cmd_modify(options)

@init_datastructs


Loading…
Cancel
Save