Skip to content
Browse files

artwork: fix artwork path computation with CUSTOM + empty filename

  • Loading branch information...
1 parent 30aa090 commit 81fc2c1198d110f4785dce28b7c5a55f459d9b3c @multani committed Feb 19, 2014
Showing with 14 additions and 1 deletion.
  1. +6 −1 sonata/artwork.py
  2. +8 −0 sonata/tests/test_artwork.py
View
7 sonata/artwork.py
@@ -102,7 +102,12 @@ def path(self, artist, album, song_dir, specific_kind=None):
if specific_kind is None:
specific_kind = self.config.art_location
- return next(iter(locations_map[specific_kind]))
+ try:
+ result = next(iter(locations_map[specific_kind]))
+ except StopIteration: # We tried an empty location :(
+ result = None
+ return result
+
def path_from_song(self, song, specific_kind=None):
"""Same as `path()` but using a Song object."""
View
8 sonata/tests/test_artwork.py
@@ -88,6 +88,14 @@ def test_find_path_from_data_as_custom_dot_jpg(self):
res = self._call_artwork_path_from_data()
self.assertEqual('/foo/To/Ta/bar.png', res)
+ def test_find_path_from_data_as_custom_without_filename(self):
+ self.config.art_location_custom_filename = ""
+ self.config.art_location = consts.ART_LOCATION_CUSTOM
+
+ res = self._call_artwork_path_from_data()
+ # We tried CUSTOM without a valid custom filename :/
+ self.assertEqual(None, res)
+
def test_find_path_from_data_force_location_type(self):
self.config.art_location = "foo bar" # Should not be used

0 comments on commit 81fc2c1

Please sign in to comment.
Something went wrong with that request. Please try again.