Skip to content

Commit

Permalink
Drop whipper caching [12/?]
Browse files Browse the repository at this point in the history
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
  • Loading branch information
JoeLametta committed Feb 22, 2020
1 parent 79d190e commit 6c080f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
1 change: 0 additions & 1 deletion whipper/command/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def do(self):
self.ittoc = self.program.getFastToc(self.runner, self.device)

# already show us some info based on this
self.program.getRipResult(self.ittoc.getCDDBDiscId())
print("CDDB disc id: %s" % self.ittoc.getCDDBDiscId())
self.mbdiscid = self.ittoc.getMusicBrainzDiscId()
print("MusicBrainz disc id %s" % self.mbdiscid)
Expand Down
50 changes: 8 additions & 42 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import time

from tempfile import NamedTemporaryFile
from whipper.common import accurip, cache, checksum, common, mbngs, path
from whipper.common import accurip, checksum, common, mbngs, path
from whipper.program import cdrdao, cdparanoia
from whipper.image import image
from whipper.extern import freedb
Expand Down Expand Up @@ -64,7 +64,6 @@ def __init__(self, config, record=False):
:param record: whether to record results of API calls for playback
"""
self._record = record
self._cache = cache.ResultCache()
self._config = config

d = {}
Expand Down Expand Up @@ -113,37 +112,19 @@ def getFastToc(self, runner, device):
def getTable(self, runner, cddbdiscid, mbdiscid, device, offset,
toc_path):
"""
Retrieve the Table either from the cache or the drive.
Retrieve the Table from the drive.
:rtype: table.Table
"""
tcache = cache.TableCache()
ptable = tcache.get(cddbdiscid, mbdiscid)
itable = None
tdict = {}

# Ignore old cache, since we do not know what offset it used.
if isinstance(ptable.object, dict):
tdict = ptable.object

if offset in tdict:
itable = tdict[offset]

if not itable:
logger.debug('getTable: cddbdiscid %s, mbdiscid %s not in cache '
'for offset %s, reading table', cddbdiscid, mbdiscid,
offset)
t = cdrdao.ReadTOCTask(device, toc_path=toc_path)
t.description = "Reading table"
runner.run(t)
itable = t.toc.table
tdict[offset] = itable
ptable.persist(tdict)
logger.debug('getTable: read table %r', itable)
else:
logger.debug('getTable: cddbdiscid %s, mbdiscid %s in cache '
'for offset %s', cddbdiscid, mbdiscid, offset)
logger.debug('getTable: loaded table %r', itable)
t = cdrdao.ReadTOCTask(device, toc_path=toc_path)
t.description = "Reading table"
runner.run(t)
itable = t.toc.table
tdict[offset] = itable
logger.debug('getTable: read table %r', itable)

assert itable.hasTOC()

Expand All @@ -153,21 +134,6 @@ def getTable(self, runner, cddbdiscid, mbdiscid, device, offset,
itable.getMusicBrainzDiscId())
return itable

def getRipResult(self, cddbdiscid):
"""
Get the persistable RipResult either from our cache or ret. a new one.
The cached RipResult may come from an aborted rip.
:rtype: result.RipResult
"""
assert self.result is None

self._presult = self._cache.getRipResult(cddbdiscid)
self.result = self._presult.object

return self.result

@staticmethod
def addDisambiguation(template_part, metadata):
"""Add disambiguation to template path part string."""
Expand Down

0 comments on commit 6c080f6

Please sign in to comment.