Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix critical regressions introduced in 3e79032 and 16b0d8d #371

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import os
import time

from whipper.common import accurip, checksum, common, mbngs, path
from whipper.common import accurip, cache, checksum, common, mbngs, path
from whipper.program import cdrdao, cdparanoia
from whipper.image import image
from whipper.extern import freedb
from whipper.extern.task import task
from whipper.result import result

import logging
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,6 +63,7 @@ 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 @@ -107,20 +107,38 @@ def getFastToc(self, runner, device):
def getTable(self, runner, cddbdiscid, mbdiscid, device, offset,
toc_path):
"""
Retrieve the Table from the drive.
Retrieve the Table either from the cache or the drive.

@rtype: L{table.Table}
"""
tcache = cache.TableCache()
ptable = tcache.get(cddbdiscid, mbdiscid)
itable = None
tdict = {}

t = cdrdao.ReadTOCTask(device)
t.description = "Reading table"
t.toc_path = toc_path
runner.run(t)
itable = t.toc.table
tdict[offset] = itable
logger.debug('getTable: read table %r' % itable)
# 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)
t.description = "Reading table"
t.toc_path = toc_path
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)

assert itable.hasTOC()

Expand All @@ -132,12 +150,15 @@ def getTable(self, runner, cddbdiscid, mbdiscid, device, offset,

def getRipResult(self, cddbdiscid):
"""
Return a RipResult object.
Retrieve the persistable RipResult either from our cache (from a
previous, possibly aborted rip), or return a new one.

@rtype: L{result.RipResult}
"""
assert self.result is None
self.result = result.RipResult()

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

return self.result

Expand Down