Slightly clearer layout for #2593, and comments

This commit is contained in:
Adrian Sampson 2017-06-15 17:51:14 -04:00
parent c840fea125
commit 009c6a4f6d

View file

@ -217,8 +217,14 @@ def all_items():
@app.route('/item/<int:item_id>/file')
def item_file(item_id):
item = g.lib.get_item(item_id)
item_path = util.syspath(item.path) if (os.name == 'nt') else (
util.py3_path(item.path))
# On Windows under Python 2, Flask wants a Unicode path. On Python 3, it
# *always* wants a Unicode path.
if os.name == 'nt':
item_path = util.syspath(item.path)
else:
item_path = util.py3_path(item.path)
response = flask.send_file(
item_path,
as_attachment=True,