Index: /Users/mh/Documents/workspace/Boom/server/Slim/Control/Queries.pm =================================================================== --- /Users/mh/Documents/workspace/Boom/server/Slim/Control/Queries.pm (revision 22998) +++ /Users/mh/Documents/workspace/Boom/server/Slim/Control/Queries.pm (working copy) @@ -1546,46 +1546,58 @@ $params->{'id'} = $folderId; } - # Pull the directory list, which will be used for looping. - my ($topLevelObj, $items, $count) = Slim::Utils::Misc::findAndScanDirectoryTree($params); - # create filtered data - - my $topPath = $topLevelObj->path; + my ($topLevelObj, $items, $count); my $osName = Slim::Utils::OSDetect::OS(); my @data; - for my $relPath (@$items) { + if ($cache->{bmf} && $cache->{bmf}->{data} + && $cache->{bmf}->{id} eq ($params->{url} || $params->{id}) + && $cache->{bmf}->{ttl} > time()) { + + @data = @{ $cache->{bmf}->{data} }; + } + else { + # Pull the directory list, which will be used for looping. + ($topLevelObj, $items, $count) = Slim::Utils::Misc::findAndScanDirectoryTree($params); + my $topPath = $topLevelObj->path; - $log->debug("relPath: $relPath" ); + for my $relPath (@$items) { + + my $url = Slim::Utils::Misc::fixPath($relPath, $topPath) || next; + + # Amazingly, this just works. :) + # Do the cheap compare for osName first - so non-windows users + # won't take the penalty for the lookup. + if ($osName eq 'win' && $url =~ /\.lnk$/i && Slim::Music::Info::isWinShortcut($url)) { + $url = Slim::Utils::Misc::fileURLFromWinShortcut($url); + } - my $url = Slim::Utils::Misc::fixPath($relPath, $topPath) || next; - - $log->debug("url: $url" ); - - # Amazingly, this just works. :) - # Do the cheap compare for osName first - so non-windows users - # won't take the penalty for the lookup. - if ($osName eq 'win' && Slim::Music::Info::isWinShortcut($url)) { - $url = Slim::Utils::Misc::fileURLFromWinShortcut($url); - } + my $item = Slim::Schema->rs('Track')->objectForUrl({ + 'url' => $url, + 'create' => 1, + 'readTags' => 1, + }); + + if (!blessed($item) || !$item->can('content_type')) { - my $item = Slim::Schema->rs('Track')->objectForUrl({ - 'url' => $url, - 'create' => 1, - 'readTags' => 1, - }); + next; + } + + # Bug: 1360 - Don't show files referenced in a cuesheet + next if ($item->content_type eq 'cur'); - if (!blessed($item) || !$item->can('content_type')) { - - next; + push @data, $item; } - - # Bug: 1360 - Don't show files referenced in a cuesheet - next if ($item->content_type eq 'cur'); + } - push @data, $item; - } + # cache results in case the same folder is queried again shortly + # should speed up Jive BMF, as only the first chunk needs to run the full loop above + $cache->{bmf} = { + id => ($params->{url} || $params->{id}), + data => \@data, + ttl => (time() + 15), + }; $count = scalar(@data); @@ -1865,7 +1877,7 @@ } # we might have changed - flush to the db to be in sync. - $topLevelObj->update; + $topLevelObj->update if $topLevelObj; $request->setStatusDone(); }