Folder Content Not Updating

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
AnnieBody
Posts: 56
Joined: Thu Apr 30, 2020 3:12 am

Re: Folder Content Not Updating

Post by AnnieBody »

Plus the TCP file after reboot. (max three files)
TCP.txt
(57.75 KiB) Downloaded 322 times
Nadahar
Posts: 1990
Joined: Tue Jun 09, 2015 5:57 pm

Re: Folder Content Not Updating

Post by Nadahar »

It is a "major work" in my definition, but UMS is open-source so anybody that think it's trivial can fix it themselves.

This is the two hurdles:

1) UMS is Java (as is Serviio). Unlike languages that can be compiled to native executable code, Java programs must be run inside a JVM. The JVM is an abstraction layer that allows Java programs to run across platforms/systems. But, this has a price. The price is that many OS specific functions aren't available. The problem isn't enumerating the drives, it is detecting when a new one is created. To do that, you need to OS to inform you that this has happened, and there is no standard way to handle this across OS'es. As such, it is not implemented in the JVM and isn't available from Java. There are workarounds to make it possible to talk to the OS APIs, but they are complicated and time-consuming to make, especially since you have to create at least 3 different solutions for Windows, macOS and Linux. It's absolutely doable, but the effort is considerable.

2) UMS was never written taking into account that shared folders could be added or removed while running. Don't ask me why, I too think this was really short-sighted by whoever made this decision - but that's how it is. Years and years with code has been added on top of this limitation, so trying to redo this now is - a huge task. It's possible of course, but it is many times the amount of work needed to fix step 1). It will very likely result in a lot of secondary bugs/problems since you have to restructure things at a quite fundamental level.
AnnieBody
Posts: 56
Joined: Thu Apr 30, 2020 3:12 am

Re: Folder Content Not Updating

Post by AnnieBody »

I understand the problem with having to fix legacy code.
I also understand from my experience working with a software development team that the impossible is remarkably easy when you stand back and accept you will have to do it, regardless!

I have made a request for an update now button through via the development board. This should be able to invoke the startup code already written and update without too much fuss.
Similarly, the code could be invoked at regular intervals autonomously in the background a 'Keep Updated' button perhaps? I think this is how Serviio do it.
You could check the entire content each time without having to do anything fancy such as checking the operating system for changed files, archived flags and the like.
This method should work without having to write different code for each OS.

I have also noted that different folders display the file list with differing times. From almost instantly, to taking many seconds, to reporting an error.
After the error, the file list is complete if you go back one step and then return! So the error is in itself in error!
Assuming the same code is reading the contents, there is obviously something amiss when similar actions result in wildly different results.
Nadahar
Posts: 1990
Joined: Tue Jun 09, 2015 5:57 pm

Re: Folder Content Not Updating

Post by Nadahar »

Not all legacy code is the same. Not all "impossible claims" are the same. Some developers will claim something is "impossible" if they don't want to, find something inconvenient, impractical or simply too much work. That doesn't mean that all developers are dishonest or incompetent. I never said this was impossible though, just that it would take a lot of effort.

It sounds to me like you've worked with lazy or incompetent developers, and by all means, there are many of those. Your assertion is overly generic and seems to be based on said preconditions.

It's not impossible to make a bicycle fly, but it's not trivial either. Sure, you can make some "hack" by putting rockets or the likes on it, but it still won't be a usable aircraft. To make a bicycle work like a practical, every-day usable, personal aircraft is quite a challenging task as I see it.

If the task instead is to make a trailer for the bicycle, lazy/dishonest developers would probably say "that's impossible" when what they really mean is "I don't think it's worth the effort", "I don't see the point". That doesn't mean that they could make it fly even if they were highly competent and honest.

If you think implementing this in UMS is trivial, by all means: Have a crack at it. Nobody will stand in your way, and if you get anywhere others will probably try to help you as well. I'm just explaining what I think the hurdles are, and why you probably won't see anybody making this in UMS anytime soon. It's not because I don't see the need, I've seen this request many times before, and I understand that it would be practical for those that use external drives.

What you're suggesting sounds to me more like a "rocket on a bicycle" than a real solution, but by all means: Go ahead and make it, you don't have to take my word for it. I see some problems with the approach though. There's a reason why I mentioned OS communication for discovery, doing a "rescan" on a timer will be extremely expensive. It has to do with how UMS does this, it builds the "content tree", parses source files, looks for cover images and subtitles and whatnot in one large mess. There's no simple way to split this apart, so you have to start the whole shibang. It might not make much of an impact on users with small media libraries, but for those with large media libraries it will be a major issue. The most "efficient way" would probably be to make some kind of a "map" over what files have been scanned and not, and make sure to only scan new ones. That's still work that has to be done though, and which adds complexity to an already very messy process.

Even if you made your timer and the "differential map" and only scanned what was needed, it wouldn't help much. The main problem is that the "media tree" is pretty much set in stone once it's made. To make it even better, there is one such media tree per connected renderer. So, without rewriting the very core logic, you wouldn't be able to reflect the changes to already connected renderers. Only "new" renderers (devices that UMS haven't seen since it was started) would see the updated "tree". It doesn't help to disconnect/turn off the renderer either, because UMS keeps this tree around for quite a time after the renderer disappears, to save time in case it shows up again. So, you would have to change how all this works, or to turn your TV off for 30 minutes or more after plugging in your new drive.

All in all, it seems to me that all this isn't worth tackling to avoid having to restart UMS after connecting a drive. You might see it differently, and that's your right. I suspect that you will come around to my point of view if you dive into the details and tries to implement this though...
AnnieBody
Posts: 56
Joined: Thu Apr 30, 2020 3:12 am

Re: Folder Content Not Updating

Post by AnnieBody »

In the meantime, can you explain why, when I wait, I finally get the listing. Then, after coming out of the folder and going back in the listing has to be read again with a similar long delay.
What is so difficult in creating a file that records, logs and restores the contents so you don't have to wait to do it every time?
You appear to have a log file that does just that but this cannot be done for folders, which incidentally the log file looks for and finds.

Why does it take so long to interrogate and report the folder contents.
Is this a Java problem too?
If this happened in the log file then UMS would be unusable.
User avatar
valib
Developer
Posts: 699
Joined: Fri Feb 08, 2013 3:11 am

Re: Folder Content Not Updating

Post by valib »

@AnnieBody the answer how to rescan shared folders when they a changed without restarting the UMS is here http://www.universalmediaserver.com/for ... 13&t=14143
Post Reply