fetchart: Fix path types on Windows

This commit is contained in:
Adrian Sampson 2016-06-08 10:20:25 -07:00
parent 27bd4c5570
commit f400a2431e
4 changed files with 11 additions and 6 deletions

View file

@ -31,6 +31,7 @@ from beets import util
from beets import config
from beets.util.artresizer import ArtResizer
from beets.util import confit
from beets.util import syspath, bytestring_path
try:
import itunes
@ -599,15 +600,16 @@ class FileSystem(LocalArtSource):
cautious = extra['cautious']
for path in paths:
if not os.path.isdir(path):
if not os.path.isdir(syspath(path)):
continue
# Find all files that look like images in the directory.
images = []
for fn in os.listdir(path):
for fn in os.listdir(syspath(path)):
fn = bytestring_path(fn)
for ext in IMAGE_EXTENSIONS:
if fn.lower().endswith(b'.' + ext.encode('utf8')) and \
os.path.isfile(os.path.join(path, fn)):
os.path.isfile(syspath(os.path.join(path, fn))):
images.append(fn)
# Look for "preferred" filenames.

View file

@ -12,6 +12,8 @@ Some fixes for Windows:
addition to forward slashes). This only applies on Windows.
* :doc:`/plugins/embedart`: Image similarity comparison with ImageMagick
should now work on Windows.
* :doc:`/plugins/fetchart`: The plugin should work more reliably with
non-ASCII paths.
Fixes:

View file

@ -454,9 +454,9 @@ class TestHelper(object):
parent = os.path.dirname(path)
if not os.path.isdir(parent):
os.makedirs(parent)
os.makedirs(util.syspath(parent))
with open(path, 'a+') as f:
with open(util.syspath(path), 'a+') as f:
f.write(content)
return path

View file

@ -18,6 +18,7 @@ from __future__ import division, absolute_import, print_function
import os
from test._common import unittest
from test.helper import TestHelper
from beets import util
class FetchartCliTest(unittest.TestCase, TestHelper):
@ -41,7 +42,7 @@ class FetchartCliTest(unittest.TestCase, TestHelper):
self.album.load()
self.assertEqual(self.album['artpath'], cover_path)
with open(cover_path, 'r') as f:
with open(util.syspath(cover_path), 'r') as f:
self.assertEqual(f.read(), 'IMAGE')
def test_filesystem_does_not_pick_up_folder(self):