|
a/src/mediaserver/cdplugins/uprcl/uprclfolders.py |
|
b/src/mediaserver/cdplugins/uprcl/uprclfolders.py |
|
... |
|
... |
71 |
# url (create intermediary directories if needed, create leaf
|
71 |
# url (create intermediary directories if needed, create leaf
|
72 |
# entry
|
72 |
# entry
|
73 |
for docidx in range(len(docs)):
|
73 |
for docidx in range(len(docs)):
|
74 |
doc = docs[docidx]
|
74 |
doc = docs[docidx]
|
75 |
|
75 |
|
|
|
76 |
arturi = docarturi(doc, httphp, pathprefix)
|
|
|
77 |
if arturi:
|
|
|
78 |
# The uri is quoted, so it's ascii and we can just store
|
|
|
79 |
# it as a doc attribute
|
|
|
80 |
doc.albumarturi = arturi
|
|
|
81 |
|
76 |
# No need to include non-audio types in the visible tree.
|
82 |
# No need to include non-audio types in the visible tree.
|
77 |
if doc.mtype not in audiomtypes:
|
83 |
if doc.mtype not in audiomtypes:
|
78 |
continue
|
84 |
continue
|
79 |
|
|
|
80 |
if doc.mtype != 'inode/directory':
|
|
|
81 |
arturi = docarturi(doc, httphp, pathprefix)
|
|
|
82 |
if arturi:
|
|
|
83 |
# The uri is quoted, so it's ascii and we can just store
|
|
|
84 |
# it as a doc attribute
|
|
|
85 |
doc.albumarturi = arturi
|
|
|
86 |
|
85 |
|
87 |
url = doc.getbinurl()
|
86 |
url = doc.getbinurl()
|
88 |
url = url[7:]
|
87 |
url = url[7:]
|
89 |
try:
|
88 |
try:
|
90 |
decoded = url.decode('utf-8')
|
89 |
decoded = url.decode('utf-8')
|
|
... |
|
... |
126 |
# If this is the last entry in the path, maybe update
|
125 |
# If this is the last entry in the path, maybe update
|
127 |
# the doc idx (previous entries were created for
|
126 |
# the doc idx (previous entries were created for
|
128 |
# intermediate elements without a Doc).
|
127 |
# intermediate elements without a Doc).
|
129 |
if idx == len(path) -1:
|
128 |
if idx == len(path) -1:
|
130 |
dirvec[fathidx][elt] = (dirvec[fathidx][elt][0], docidx)
|
129 |
dirvec[fathidx][elt] = (dirvec[fathidx][elt][0], docidx)
|
|
|
130 |
#uplog("updating docidx for %s" % decoded)
|
131 |
# Update fathidx for next iteration
|
131 |
# Update fathidx for next iteration
|
132 |
fathidx = dirvec[fathidx][elt][0]
|
132 |
fathidx = dirvec[fathidx][elt][0]
|
133 |
else:
|
133 |
else:
|
134 |
# Element has no entry in father directory (hence no
|
134 |
# Element has no entry in father directory (hence no
|
135 |
# dirvec entry either).
|
135 |
# dirvec entry either).
|
|
... |
|
... |
139 |
fathidx = _createdir(dirvec, fathidx, -1, elt)
|
139 |
fathidx = _createdir(dirvec, fathidx, -1, elt)
|
140 |
else:
|
140 |
else:
|
141 |
# Last element. If directory, needs a dirvec entry
|
141 |
# Last element. If directory, needs a dirvec entry
|
142 |
if doc.mtype == 'inode/directory':
|
142 |
if doc.mtype == 'inode/directory':
|
143 |
fathidx = _createdir(dirvec, fathidx, docidx, elt)
|
143 |
fathidx = _createdir(dirvec, fathidx, docidx, elt)
|
|
|
144 |
#uplog("Setting docidx for %s" % decoded)
|
144 |
else:
|
145 |
else:
|
145 |
dirvec[fathidx][elt] = (-1, docidx)
|
146 |
dirvec[fathidx][elt] = (-1, docidx)
|
146 |
|
147 |
|
147 |
if False:
|
148 |
if False:
|
148 |
for ent in dirvec:
|
149 |
for ent in dirvec:
|
|
... |
|
... |
240 |
entries = []
|
241 |
entries = []
|
241 |
|
242 |
|
242 |
# The basename call is just for diridx==0 (topdirs). Remove it if
|
243 |
# The basename call is just for diridx==0 (topdirs). Remove it if
|
243 |
# this proves a performance issue
|
244 |
# this proves a performance issue
|
244 |
for nm,ids in g_dirvec[diridx].iteritems():
|
245 |
for nm,ids in g_dirvec[diridx].iteritems():
|
245 |
#uplog("folders:browse: got nm %s" % nm.decode('utf-8'))
|
246 |
uplog("folders:browse: got nm %s" % printable(nm))
|
246 |
if nm == "..":
|
247 |
if nm == "..":
|
247 |
continue
|
248 |
continue
|
248 |
thisdiridx = ids[0]
|
249 |
thisdiridx = ids[0]
|
249 |
thisdocidx = ids[1]
|
250 |
thisdocidx = ids[1]
|
|
|
251 |
if thisdocidx >= 0:
|
|
|
252 |
doc = g_alldocs[thisdocidx]
|
|
|
253 |
else:
|
|
|
254 |
uplog("No doc for %s" % pid)
|
|
|
255 |
doc = None
|
|
|
256 |
|
250 |
if thisdiridx >= 0:
|
257 |
if thisdiridx >= 0:
|
251 |
# Skip empty directories
|
258 |
# Skip empty directories
|
252 |
if len(dirvec[thisdiridx]) == 1:
|
259 |
if len(dirvec[thisdiridx]) == 1:
|
253 |
continue
|
260 |
continue
|
254 |
id = g_myprefix + '$' + 'd' + str(thisdiridx)
|
261 |
id = g_myprefix + '$' + 'd' + str(thisdiridx)
|
|
|
262 |
if doc and doc.albumarturi:
|
|
|
263 |
arturi = doc.albumarturi
|
|
|
264 |
else:
|
255 |
arturi = arturifordir(thisdiridx)
|
265 |
arturi = arturifordir(thisdiridx)
|
256 |
entries.append(rcldirentry(id, pid, os.path.basename(nm),
|
266 |
entries.append(rcldirentry(id, pid, os.path.basename(nm),
|
257 |
arturi=arturi))
|
267 |
arturi=arturi))
|
258 |
else:
|
268 |
else:
|
259 |
# Not a directory. docidx had better been set
|
269 |
# Not a directory. docidx had better been set
|
260 |
if thisdocidx == -1:
|
270 |
if thisdocidx == -1:
|