* Address issue #24
* Remove getReadCaches() & replace it with getCache()

Now whipper always follows XDG specifications. All changes were documented into the README file.

The changes introduced here aren't backward compatible so, after updating whipper, you may need to configure it again (old config file are retained, though).
This commit is contained in:
JoeLametta
2016-10-09 17:26:06 +02:00
committed by GitHub
parent 4d81a02f0c
commit 746dc6599d
6 changed files with 71 additions and 77 deletions

View File

@@ -162,8 +162,8 @@ class ResultCache(log.Loggable):
self._pcache = PersistedCache(self._path)
def _getResultCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'result')
d = directory.Directory()
path = d.getCache('result')
return path
def getRipResult(self, cddbdiscid, create=True):
@@ -210,33 +210,26 @@ class TableCache(log.Loggable):
if not path:
d = directory.Directory()
self._path = d.getCache('table')
self._readPaths = d.getReadCaches('table')
else:
self._path = path
self._readPaths = [path, ]
self._pcache = PersistedCache(self._path)
self._readPCaches = [PersistedCache(p) for p in self._readPaths]
def get(self, cddbdiscid, mbdiscid):
# Before 0.2.1, we only saved by cddbdiscid, and had collisions
# mbdiscid collisions are a lot less likely
for pcache in self._readPCaches:
ptable = pcache.get('mbdiscid.' + mbdiscid)
if ptable.object:
break
ptable = self._pcache.get('mbdiscid.' + mbdiscid)
if not ptable.object:
for pcache in self._readPCaches:
ptable = pcache.get(cddbdiscid)
if ptable.object:
if ptable.object.getMusicBrainzDiscId() != mbdiscid:
self.debug('cached table is for different mb id %r' % (
ptable.object.getMusicBrainzDiscId()))
ptable.object = None
else:
self.debug('no valid cached table found for %r' %
cddbdiscid)
ptable = self._pcache.get(cddbdiscid)
if ptable.object:
if ptable.object.getMusicBrainzDiscId() != mbdiscid:
self.debug('cached table is for different mb id %r' % (
ptable.object.getMusicBrainzDiscId()))
ptable.object = None
else:
self.debug('no valid cached table found for %r' %
cddbdiscid)
if not ptable.object:
# get an empty persistable from the writable location