Very small suggestion for managing directories

Forums:

Hey! I'm using MOC to play from directories managed by git-annex. When I don't have a file locally from my git-annex repository, it shows up as a dead symlink when browsing the directories. This works great in MOC, because dead symlinks don't show up when using its file viewer. I'm wondering about something that would make my browsing in MOC go from ok to fantastic.

Would it be possible to add an option or just change the functionality of MOC so that an empty directory, or a directory that contains nothing but more empty directories and/or dead symlinks would not show up? It'd it would make the front-end absolutely flawless for my music playing experience.

I organize pretty much all my music by Artist -> Album -> Song where the first two are directories. If this feature would be implemented properly, all dead symlinks would be seen as empty directories. Then when I had no albums of a particular artist downloaded, the artist wouldn't show up in the file viewer for MOC, even though the artist and album directories would still exist. When I had only a few out of the total albums from the artist, the artist directory would show up in MOC, but only a few of the albums would show up. And when I had simply a few songs of a particular album, MOC would function as it already does where the songs that weren't downloaded wouldn't show up (the symlinks that are dead would be ignored).

From what I can tell, this wouldn't be that large of a change, so I hope this suggestion is put into place. I'm happy to answer any questions to make sure this is executed properly.

I'm using MOC to play from directories managed by git-annex.

Great! I'd love to use git-annex... if only it weren't for the large and difficult-to-build Haskell interpreter requirement.

Would it be possible to add an option or just change the functionality of MOC so that an empty directory, or a directory that contains nothing but more empty directories and/or dead symlinks would not show up?

That sounds quite reasonable. It is a matter of individual preference, of course, so would need to be selected via a configuration option.

My only concern would be the cost of drilling down through the directory tree to determine whether or not any of the sub-directories are populated (particularly on NFS-mounted filesystems) but the option would mitigate that. Also bear in mind that testing MOC's support for each file in the directory tree to determine whether or not they can be played (and therefore displayed) could be a significant CPU and I/O load with directory trees containing a large number of sub-directories; maybe an additional option (or original option value) may be required to say that the presence of a file is sufficient to include the directory on the assumption that it can be played if and when the time comes.

As it happens, I am currently working on ("working" as in I have a patch which needs further work and the time to continue with it) which refactors the directory reading code in MOC, so I'll look at adding this requirement into it.

Thank you for looking at this for your patch! I've tried looking at the code myself, but I don't think I have any practical way to implement feature.

I realize checking the entire directory tree would be intense on the processor, so I'm assuming this idea would require the option of some sort of user-invoked, recusive scan of the current directory which would be cached at a place like ~/.moc/cache. A lot of MOC's benefit is the ability to handle enormous music libraries, so I wouldn't want this feature to intrude on anyone else's use-cases. The full scan might only be possible if the option to hide "empty" directories was enabled so that no one needs waste their time by scanning if they don't need to.

Of course, I'm no programmer to this project, so if there's a better idea you could suggest, I'm happy to hear it - this is just what I could think of off the top of my head. Maybe an even easier, hacky solution would be to allow the showing/hiding of directories so that I could manage what files I have downloaded manually. Then I could try my best to script a hook into git annex to automatically update the MOC show/hide cache or something like that. Actually, that's not a half-bad idea now that I say it. Maybe that'd be easier to implement right now?

Do you have any ideas about when this patch you're working on might be finished? Otherwise, do you have any recommendations as to how I could implement either suggestion myself and recompile?

Thanks again.