Conversation
|
Hello, A couple of questions/remarks: People who browse by folders usually don't rely on tags. Does it make sense to apply global filters in this view? If someone wants to browse by tag, properly tagging tracks with all the relevant information and using the existing views would be the way to go. This would eliminate a lot of complexity since there would be no need to filter out empty or non-matching folders. Furthermore, speed is really a concern: this view should be very fast, even on limited hardware like a Raspberry Pi. I planned to add more entries to the top-level navbar, such as an entry to list podcasts and their episodes and a search widget to restore the multi-search feature, but I am not pleased with that since:
Can you rebase on |
|
I've removed the filtered path from the folders view, as well as some of the ropier stuff around the URL routing, to make it easier to review. Note that we still have the complexity around hiding empty dirs - this is only an issue in the unfiltered path, as no filter can ever match an empty dir. The same mechanism also gives us the direct-linking of album directories for free. I don't think this should be a problem for sqlite, even on a less-powerful machine. If necessary we could add a "hide empty folders" config option. I have a raspberry pi I can test on, as well as a synology NAS that I actually use LMS on. What's your threshold for a fast pageload, and for a large library? I rebased to develop also. |
This PR adds folder browsing functionality to the web interface.
The way this works is it displays a list of subdirectories of the current dir, and a list of releases in that dir. It doesn't ever display individual tracks per-directory.
When a directory contains a single release (the common case for leaf dirs) the link for that row is set to target the release directly. Additionally, as the
directorytable in the database contains data used by the album art and other subsystems, not just audio files, the queries are set up to ensure that directories in the list must contain at least one release. This prevents the inclusion ofcoversdirectories and so on.As you might imagine this requires somewhat acrobatic SQL. We have two codepaths, filtered and unfiltered. In the unfiltered case, we have queries like this:
This might look a little ugly, with the subqueries and the HAVING and so on but I tried a lot of variations and this is the fastest I came up with, it needs to be set up like this to stop it self-joining to the whole table. With this design it lists the root of my ~60k track library in <30ms. A folder with a very large number of albums takes ~200ms.
Here's what it looks like when a filter is applied:
The situation here is that we still need to be counting the releases in each result, to get the direct-linking-of-single-release-dirs behavior, but we need to apply the filtering to the whole subtree, to find matching tracks deep below the current browsing level. (We get the no-empty-leaves behavior for free from the filter matching.)
The way I've handled it is that we apply the filters once, in the base case of the CTE, and then we reverse-walk up the directory tree to the root for each match. This ensures that in the typical case of a narrow filter, we only perform the expensive recursion on the actually-matching resultset. The worst case is then a very permissive filter, which means a lot of walks. In practice, when filtering my library for FLACs, which matches the majority of the files, I still couldn't get the pageload to take longer than a couple of hundred ms.
The other UX thing I wanted was that in the case of a single music library, the Folders link in the header should go directly to that library, rather than showing a list of one item. This requires an extra query when building the header, but that only happens when starting a new session, and its cheap anyway.
Stuff that I didn't add includes linking from the Release page back to the folder view, I might try and add that later. Also I didn't implement pagination, instead just trying to make it fast.