diff --git a/beetsplug/ipfs.py b/beetsplug/ipfs.py index 87a100b14..9a9d6aa50 100644 --- a/beetsplug/ipfs.py +++ b/beetsplug/ipfs.py @@ -272,9 +272,11 @@ class IPFSPlugin(BeetsPlugin): break except AttributeError: pass + item_path = os.path.basename(item.path).decode( + util._fsencoding(), 'ignore' + ) # Clear current path from item - item.path = '/ipfs/{0}/{1}'.format(album.ipfs, - os.path.basename(item.path)) + item.path = '/ipfs/{0}/{1}'.format(album.ipfs, item_path) item.id = None items.append(item) diff --git a/test/test_ipfs.py b/test/test_ipfs.py index 61f10dc92..228575fd8 100644 --- a/test/test_ipfs.py +++ b/test/test_ipfs.py @@ -17,7 +17,7 @@ from __future__ import division, absolute_import, print_function from mock import patch from beets import library -from beets.util import bytestring_path +from beets.util import bytestring_path, _fsencoding from beetsplug.ipfs import IPFSPlugin from test import _common @@ -51,9 +51,11 @@ class IPFSPluginTest(unittest.TestCase, TestHelper): for check_item in added_album.items(): try: if check_item.ipfs: + ipfs_item = os.path.basename(want_item.path).decode( + _fsencoding(), + ) want_path = '/ipfs/{0}/{1}'.format(test_album.ipfs, - os.path.basename( - want_item.path)) + ipfs_item) want_path = bytestring_path(want_path) self.assertEqual(check_item.path, want_path) self.assertEqual(check_item.ipfs, want_item.ipfs)