key on musicbrainz disc id by default

Do not use cache if the mb disc id does not match the table cache value.

Fixes asserts on the mb disc id differing.

Fixes trac ticket 103.
This commit is contained in:
Thomas Vander Stichele
2013-02-03 22:20:00 +01:00
parent d4c81126d5
commit e3b168c2a1
3 changed files with 12 additions and 13 deletions

View File

@@ -67,11 +67,6 @@ class Program(log.Loggable):
self._cache = cache.ResultCache()
self._stdout = stdout
def _getTableCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'table')
return path
def setWorkingDirectory(self, workingDirectory):
if workingDirectory:
self.info('Changing to working directory %s' % workingDirectory)
@@ -139,7 +134,7 @@ class Program(log.Loggable):
assert toc.hasTOC()
return toc
def getTable(self, runner, cddbdiscid, device):
def getTable(self, runner, cddbdiscid, mbdiscid, device):
"""
Retrieve the Table either from the cache or the drive.
@@ -147,12 +142,13 @@ class Program(log.Loggable):
"""
path = self._getTableCachePath()
pcache = cache.PersistedCache(path)
ptable = pcache.get(cddbdiscid)
tcache = cache.TableCache()
ptable = tcache.get(cddbdiscid, mbdiscid)
if not ptable.object:
self.debug('getTable: cddbdiscid %s not in cache, reading table' %
cddbdiscid)
self.debug('getTable: cddbdiscid %s, mbdiscid %s not in cache, '
'reading table' % (
cddbdiscid, mbdiscid))
t = cdrdao.ReadTableTask(device=device)
runner.run(t)
ptable.persist(t.table)

View File

@@ -368,7 +368,7 @@ class Table(object, log.Loggable):
assert len(result) == 28, \
"Result should be 28 characters, not %d" % len(result)
self.debug('getMusicBrainzDiscId: returning %r' % result)
self.log('getMusicBrainzDiscId: returning %r' % result)
return result
def getMusicBrainzSubmitURL(self):
@@ -455,7 +455,7 @@ class Table(object, log.Loggable):
pass
self.debug('Musicbrainz values: %r', result)
self.log('Musicbrainz values: %r', result)
return result
def getAccurateRipIds(self):

View File

@@ -94,7 +94,10 @@ class _CD(logcommand.LogCommand):
return -1
# now, read the complete index table, which is slower
self.itable = self.program.getTable(self.runner, self.ittoc.getCDDBDiscId(), self.device)
self.itable = self.program.getTable(self.runner,
self.ittoc.getCDDBDiscId(),
self.ittoc.getMusicBrainzDiscId(), self.device)
assert self.itable.getCDDBDiscId() == self.ittoc.getCDDBDiscId(), \
"full table's id %s differs from toc id %s" % (