* morituri/common/program.py:

* morituri/rip/cd.py:
	  Serialize the rip result after every rip, so we can pick up
	  where we left off with all result data.
This commit is contained in:
Thomas Vander Stichele
2009-06-09 19:39:59 +00:00
parent 5652cee15e
commit 1efa2d7b20
3 changed files with 50 additions and 5 deletions

View File

@@ -127,21 +127,26 @@ class Program(object):
@ivar metadata:
@type metadata: L{DiscMetadata}
@ivar result: the rip's result
@type result: L{result.RipResult}
"""
cuePath = None
logPath = None
metadata = None
outdir = None
def __init__(self):
self.result = result.RipResult()
result = None
def _getTableCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'table')
return path
def _getResultCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'result')
return path
def unmountDevice(self, device):
"""
Unmount the given device if it is mounted, as happens with automounted
@@ -174,6 +179,32 @@ class Program(object):
return itable
def getRipResult(self, cddbdiscid):
"""
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
path = self._getResultCachePath()
pcache = common.PersistedCache(path)
presult = pcache.get(cddbdiscid)
if not presult.object:
presult.object = result.RipResult()
presult.persist(self.result)
self.result = presult.object
self._presult = presult
return self.result
def saveRipResult(self):
self._presult.persist()
def getPath(self, outdir, template, mbdiscid, i):
"""
Based on the template, get a complete path for the given track,