Handle missing tag cache better

This commit is contained in:
Thomas Adamcik 2010-04-30 20:46:30 +02:00
parent a222a49799
commit fa362ce936
3 changed files with 9 additions and 4 deletions

View File

@ -185,6 +185,7 @@ class GStreamerLibraryController(BaseLibraryController):
def __init__(self, backend):
super(GStreamerLibraryController, self).__init__(backend)
self._uri_mapping = {}
self.refresh()
def refresh(self, uri=None):
tracks, artists, albums = parse_mpd_tag_cache(settings.TAG_CACHE,

View File

@ -140,12 +140,17 @@ def parse_mpd_tag_cache(tag_cache, music_dir=''):
"""
Converts a MPD tag_cache into a lists of tracks, artists and albums.
"""
with open(tag_cache) as library:
contents = library.read()
tracks = set()
artists = set()
albums = set()
try:
with open(tag_cache) as library:
contents = library.read()
except IOError, e:
logger.error('Could not tag cache: %s', e)
return tracks, artists, albums
current = {}
state = None

View File

@ -989,7 +989,6 @@ class BaseLibraryControllerTest(object):
def setUp(self):
self.backend = self.backend_class(mixer=DummyMixer())
self.library = self.backend.library
self.library.refresh() # FIXME init should call refresh instead
def tearDown(self):
self.backend.destroy()