From bc8a8ecf5f819facc8dbe088a3829ebd6acfb1e2 Mon Sep 17 00:00:00 2001 From: robot3498712 Date: Thu, 15 Jun 2017 12:49:00 +0200 Subject: [PATCH 1/2] fix /issues/2592: web: Use Unicode paths to send files on Windows under Python 2 --- beetsplug/web/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 290f25b48..14e338ba6 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -217,12 +217,13 @@ def all_items(): @app.route('/item//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) response = flask.send_file( - util.py3_path(item.path), + item_path, as_attachment=True, attachment_filename=os.path.basename(util.py3_path(item.path)), ) - response.headers['Content-Length'] = os.path.getsize(item.path) + response.headers['Content-Length'] = os.path.getsize(item_path) return response From cafbb2438e90727ae48c00324cda5f8309ab544c Mon Sep 17 00:00:00 2001 From: robot3498712 Date: Thu, 15 Jun 2017 13:27:28 +0200 Subject: [PATCH 2/2] fixed failing test - line too long --- beetsplug/web/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 14e338ba6..00718dbfb 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -217,7 +217,8 @@ def all_items(): @app.route('/item//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) + item_path = util.syspath(item.path) if (os.name == 'nt') else ( + util.py3_path(item.path)) response = flask.send_file( item_path, as_attachment=True,