[Solved] Compressed archives streaming wrong files

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
Post Reply
seisuke
Posts: 3
Joined: Wed Oct 09, 2024 9:35 pm

[Solved] Compressed archives streaming wrong files

Post by seisuke »

I have switched to version 14.4.0 a while ago and I noticed a problem when opening compressed zip archives.

I usually sort images into archives as that makes the copying around easier and diplaying with UMS used to work fine on a previous version. Previously I think used 10.4.1. I can't be sure though as I do not remember exactly and 10.4.1 is the version still im donwload folder, so it is my best guess.

The problem looks like this:
When I open an archive with jpg or png images, I see the correct file list in the compressed folder. But only the first image is streamed, no matter the file name. Reproducing the bug I also noticed that it depends on the file extension. In the test archive I made, I included png and jpg files. The jpg files all look like the first jpg in the list. The png files look like the first png file. This only happens with compressed archives. Images in normal folder work fine.

I tried going back to 10.4.1 but now that version does not even show the file list of a compressed folder anymore.
I also tried 14.5.0. But the problem is on that version als well. I just dont use 14.5.0 because it seems to cause worse quality when streaming video file. But that is a different issue.

Any idea how to fix this issue with compressed archives?
Attachments
ums_dbg_2024-10-09-11-34.zip
(402.74 KiB) Downloaded 280 times
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Compressed archives streaming wrong files

Post by mik_s »

I think I see what is wrong. UMS is assigning the same IDs to each file-type in an archive (5503 for .jpg and 5502 for .png in this case) so whatever file the renderer requests it will be sent the first of that type.

Code: Select all

<item id="5502" parentID="5501" restricted="1">
	<dc:title>4_by_redmorpho-d95y612.png</dc:title>
	<res xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" protocolInfo="http-get:*:image/png:DLNA.ORG_OP=01" size="3144608">http://192.168.178.50:5001/ums/media/dc7e4336-a85b-3ee0-ac8d-5a5bfb607e83/5502/4_by_redmorpho-d95y612.png</res>
	<upnp:class>object.item.imageItem.photo</upnp:class>
</item>
<item id="5503" parentID="5501" restricted="1">
	<dc:title>610606b1eaa1a195c481f06bce846fb3-d6adsm9.jpg</dc:title>
	<res xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" protocolInfo="http-get:*:image/jpeg:DLNA.ORG_OP=01" size="298043">http://192.168.178.50:5001/ums/media/dc7e4336-a85b-3ee0-ac8d-5a5bfb607e83/5503/610606b1eaa1a195c481f06bce846fb3-d6adsm9.jpg</res>
	<upnp:class>object.item.imageItem.photo</upnp:class>
</item>
<item id="5503" parentID="5501" restricted="1">
	<dc:title>Adria.jpg</dc:title>
	<res xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" protocolInfo="http-get:*:image/jpeg:DLNA.ORG_OP=01" size="338942">http://192.168.178.50:5001/ums/media/dc7e4336-a85b-3ee0-ac8d-5a5bfb607e83/5503/Adria.jpg</res>
			<upnp:class>object.item.imageItem.photo</upnp:class>
</item>
<item id="5502" parentID="5501" restricted="1">
	<dc:title>radan_the_rogue_by_robertogatto-d7zllth.png</dc:title>
	<res xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" protocolInfo="http-get:*:image/png:DLNA.ORG_OP=01" size="526311">http://192.168.178.50:5001/ums/media/dc7e4336-a85b-3ee0-ac8d-5a5bfb607e83/5502/radan_the_rogue_by_robertogatto-d7zllth.png</res>
	<upnp:class>object.item.imageItem.photo</upnp:class>
</item>
This is similar to something that happened with subtitles in V14 beta when I was testing it where all subtitles would return the last one, usually Turkish.
I'll make an issue on Github.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
seisuke
Posts: 3
Joined: Wed Oct 09, 2024 9:35 pm

Re: Compressed archives streaming wrong files

Post by seisuke »

I have an update from my side.

After debuggung the process distributung the file id, I realised the id is given by the MediaStore depending on the systemName of the resource.

Code: Select all

public static MediaStoreId getResourceMediaStoreId(Connection connection, StoreResource resource) {
		if (connection == null || resource == null || resource.getParent() == null || resource.getParent().getLongId() == null) {
			return null;
		}
		long parentId = resource.getParent().getLongId();
		String name = resource.getSystemName();
The method for the system name of zipped entries looks like this in

package net.pms.store.item.ZippedEntry:

Code: Select all

public String getSystemName() {
		return FileUtil.getFileNameWithoutExtension(file.getAbsolutePath()) + "." + FileUtil.getExtension(zeName);
	}
This returns the path of the zip archive file + the extension of the image file. So it looks something like "C:\\ZipArchive.jpg" or "C:\\ZipArchive.png" for every file in the archive of the same file type. Thus the MediaStore keeps getting requests for the same SystemName and returns the already generated ids. I changed the code to include the file name of the zip entry like this:

Code: Select all

public String getSystemName() {
		return FileUtil.getFileNameWithoutExtension(file.getAbsolutePath()) + "\\" + FileUtil.getFileNameWithoutExtension(zeName) + "." + FileUtil.getExtension(zeName);
	}
This seems to fix the id problem and initial testing looked fine on my side. I don't know if this will have any side effects though. So it would be nice to get some optinions on this change.
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Compressed archives streaming wrong files

Post by mik_s »

I'm not a programmer but that does makes sense if the zipped file filename was never added so would always return the same ID, so that looks like the right fix.

You could open a pull request with this on Github to get this fixed.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
User avatar
mik_s
Moderator
Posts: 1430
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Compressed archives streaming wrong files

Post by mik_s »

I made a pull request for you and gave you the credit for finding this.

Edit: there was more to it than just this as it does not fix browsing folders and other archive types. Should be fixed by #5024
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
User avatar
SubJunk
Lead Developer
Posts: 3797
Joined: Sun May 27, 2012 4:12 pm

Re: Compressed archives streaming wrong files

Post by SubJunk »

Thanks for the work on this you two. I think this is fixed now. Would you like me to send you a fixed build, seisuke?
seisuke
Posts: 3
Joined: Wed Oct 09, 2024 9:35 pm

Re: Compressed archives streaming wrong files

Post by seisuke »

Thanks, but no need to do that. I got the fix running on my system already.
Post Reply