From 27d50ef044ab66d77abdb9f5b94d7c568dad035f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 16 Dec 2015 10:30:07 +0000 Subject: mlib: wire up search/find/stats to the UI Not in any way a stable interface, yet, and still incomplete. This should emulate parts of the mpd protocol which should make it easier to debug and develop. --- lib/dtas/mlib.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb index b81ec54..0d2f70c 100644 --- a/lib/dtas/mlib.rb +++ b/lib/dtas/mlib.rb @@ -212,6 +212,7 @@ class DTAS::Mlib # :nodoc: q = { parent_id: 1, # self name: '', + dirname: '', } node = @db[:nodes][q] and return (@root_node = node) begin @@ -378,10 +379,10 @@ class DTAS::Mlib # :nodoc: def path_of(node, cache) base = node[:name] - return '/' if base == '' + return '/' if base == '' # root_node parent_id = node[:parent_id] base += '/' unless node[:tlen] >= 0 - ppath = cache[parent_id] and return "#{ppath}#{base}" + ppath = cache[parent_id] and return "#{ppath}/#{base}" parts = [] begin node = @db[:nodes][id: node[:parent_id]] @@ -389,8 +390,9 @@ class DTAS::Mlib # :nodoc: parts.unshift node[:name] end while true parts.unshift('') - parts << base cache[parent_id] = parts.join('/') + parts << base + parts.join('/') end def emit_recurse(node, cache, cb) -- cgit v1.2.3-24-ge0c7