Commit 1b4f8e5b authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

Restore compat with recoll 1.27

parent dc1a7e1e
......@@ -91,6 +91,8 @@ try:
_has_resultstore = True
except:
_has_resultstore = False
uprclutils.sethasresultstore(_has_resultstore)
from recoll import rclconfig
import uprclinit
......@@ -162,7 +164,10 @@ class Folders(object):
if not os.path.isabs(path):
path = os.path.join(os.path.dirname(plpath), path)
doc = recoll.Doc()
doc["url"] = b'file://' + path
if _has_resultstore:
doc["url"] = b'file://' + path
else:
doc.setbinurl(bytearray(b'file://' + path))
fathidx, docidx = self._stat(doc)
if docidx >= 0 and docidx < len(self._rcldocs):
return docidx
......@@ -173,13 +178,13 @@ class Folders(object):
# Create bogus doc for external (http) url. This is for playlists.
def docforurl(self, url):
doc = recoll.Doc()
doc["url"] = url
doc.url = url
elt = os.path.split(url)[1]
tt = elt.decode('utf-8', errors='ignore')
doc["title"] = tt
doc.title = tt
# Temp workaround for recoll 1.28.2 not setting values in meta
doc["text"] = tt
doc["mtype"] = "audio/mpeg"
doc.text = tt
doc.mtype = "audio/mpeg"
return doc
......
......@@ -32,6 +32,11 @@ from upmplgutils import uplog
# This must be consistent with what contentdirectory.cxx does
g_myprefix = '0$uprcl$'
_has_resultstore = False
def sethasresultstore(v):
global _has_resultstore
_has_resultstore = v
audiomtypes = frozenset([
'audio/mpeg',
'audio/flac',
......@@ -147,15 +152,26 @@ def rcldoctoentry(id, pid, httphp, pathprefix, doc):
path = doc["url"]
ssidx = path.find('//')
if path.find('file://') == 0:
path = path[7:]
path = os.path.join(pathprefix.encode('ascii'), urlunquotetobytes(path))
li['uri'] = _httpurl(httphp, path)
# Versions of recoll with the resultstore urlencode the url
# field (and we actually store it in the resultstore, not in
# an rcl::doc), we decode it to binary. For older
# versions, we need to call doc.getbinurl() In any case, we
# take a lot of care to preserve non-decodable (e.g. iso88859
# in an utf-8 locale) paths, but bottle currently can't stream
# them. For reference, minim does not process them at all. At
# least we're almost there...
# Cf beethovem/p-s-g/vol1/cd3 path('e)tique
if _has_resultstore:
bpath = urlunquotetobytes(path[ssidx+2:])
else:
bpath = doc.getbinurl()[ssidx+2:]
li['uri'] = _httpurl(httphp, bpath)
else:
li['uri'] = path[:ssidx+2] + urlquote(path[ssidx+1:])
li['uri'] = path[:ssidx+2] + urlquote(path[ssidx+2:])
#uplog("rcldoctoentry: uri: %s" % li['uri'])
if 'tt' not in li:
li['tt'] = os.path.basename(path[ssidx+1:])
li['tt'] = os.path.basename(path[ssidx+2:])
return li
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment