Skip to content

Commit

Permalink
artwork: fix artwork path computation with CUSTOM + empty filename
Browse files Browse the repository at this point in the history
  • Loading branch information
multani committed Feb 19, 2014
1 parent 30aa090 commit 81fc2c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sonata/artwork.py
Expand Up @@ -102,7 +102,12 @@ def path(self, artist, album, song_dir, specific_kind=None):
if specific_kind is None: if specific_kind is None:
specific_kind = self.config.art_location 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): def path_from_song(self, song, specific_kind=None):
"""Same as `path()` but using a Song object.""" """Same as `path()` but using a Song object."""
Expand Down
8 changes: 8 additions & 0 deletions sonata/tests/test_artwork.py
Expand Up @@ -88,6 +88,14 @@ def test_find_path_from_data_as_custom_dot_jpg(self):
res = self._call_artwork_path_from_data() res = self._call_artwork_path_from_data()
self.assertEqual('/foo/To/Ta/bar.png', res) 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): def test_find_path_from_data_force_location_type(self):
self.config.art_location = "foo bar" # Should not be used self.config.art_location = "foo bar" # Should not be used


Expand Down

0 comments on commit 81fc2c1

Please sign in to comment.