@@ -151,29 +151,39 @@ def function(r, t):
151151 assert toc .hasTOC ()
152152 return toc
153153
154- def getTable (self , runner , cddbdiscid , mbdiscid , device ):
154+ def getTable (self , runner , cddbdiscid , mbdiscid , device , offset ):
155155 """
156156 Retrieve the Table either from the cache or the drive.
157157
158158 @rtype: L{table.Table}
159159 """
160160 tcache = cache .TableCache ()
161161 ptable = tcache .get (cddbdiscid , mbdiscid )
162+ itable = None
163+ tdict = {}
162164
163- if not ptable .object :
164- self .debug ('getTable: cddbdiscid %s, mbdiscid %s not in cache, '
165+ # Ingore old cache, since we do not know what offset it used.
166+ if type (ptable .object ) is dict :
167+ tdict = ptable .object
168+
169+ if offset in tdict :
170+ itable = tdict [offset ]
171+
172+ if not itable :
173+ self .debug ('getTable: cddbdiscid %s, mbdiscid %s not in cache for offset %s, '
165174 'reading table' % (
166- cddbdiscid , mbdiscid ))
175+ cddbdiscid , mbdiscid , offset ))
167176 t = cdrdao .ReadTableTask (device = device )
168177 runner .run (t )
169- ptable .persist (t .table )
170- self .debug ('getTable: read table %r' % t .table )
178+ itable = t .table
179+ tdict [offset ] = itable
180+ ptable .persist (tdict )
181+ self .debug ('getTable: read table %r' % itable )
171182 else :
172- self .debug ('getTable: cddbdiscid %s, mbdiscid %s in cache' % (
173- cddbdiscid , mbdiscid ))
174- ptable .object .unpickled ()
175- self .debug ('getTable: loaded table %r' % ptable .object )
176- itable = ptable .object
183+ self .debug ('getTable: cddbdiscid %s, mbdiscid %s in cache for offset %s' % (
184+ cddbdiscid , mbdiscid , offset ))
185+ self .debug ('getTable: loaded table %r' % itable )
186+
177187 assert itable .hasTOC ()
178188
179189 self .result .table = itable
@@ -182,8 +192,6 @@ def getTable(self, runner, cddbdiscid, mbdiscid, device):
182192 itable .getMusicBrainzDiscId ())
183193 return itable
184194
185- # FIXME: the cache should be model/offset specific
186-
187195 def getRipResult (self , cddbdiscid ):
188196 """
189197 Retrieve the persistable RipResult either from our cache (from a
0 commit comments