Playback of federated tracks fails when track has spaces in path filename
Steps to reproduce
- Subscribe to a public channel like
plus4_allstars@stereo.kenobit.it
- Try to listen to a track
What happens?
Track does not play, errors are shown in nginx error log.
2024/02/19 16:29:53 [error] 531592#531592: *320559 open() "/webapp/funkwhale/site/data/media/federation_cache/tracks/dd/02/75/5tarbuck%20-%20Dungeon%20and%20Underground%20-%20Pets%20Rescue%20Soundtrack%20-%20Plus/4-all-stars.mp3" failed (2: No such file or directory), client: 151.14.38.31, server: music.valo.space, request: "GET /api/v1/listen/b863333e-335e-45c4-9bbb-8be144467c95/?upload=2d2b7c4e-bad1-4b3d-b684-fc1ec3961f84&token=eyJ1c2VyX2lkIjoxLCJ1c2VyX3NlY3JldCI6IjQxM2UxNDYwLTk5ZTUtNDM1Ni04N2YwLWY3OGUwNDM1NjJhOCIsInNjb3BlcyI6WyJyZWFkOmxpYnJhcmllcyJdfQ%3A1rc4TV%3AelBSxI9PRUbEi2XjizjukC5NJKdg1h48hQhavmxCVqk HTTP/2.0", upstream: "http://127.0.0.1:5000/api/v1/listen/b863333e-335e-45c4-9bbb-8be144467c95/?upload=2d2b7c4e-bad1-4b3d-b684-fc1ec3961f84&token=eyJ1c2VyX2lkIjoxLCJ1c2VyX3NlY3JldCI6IjQxM2UxNDYwLTk5ZTUtNDM1Ni04N2YwLWY3OGUwNDM1NjJhOCIsInNjb3BlcyI6WyJyZWFkOmxpYnJhcmllcyJdfQ%3A1rc4TV%3AelBSxI9PRUbEi2XjizjukC5NJKdg1h48hQhavmxCVqk", host: "music.valo.space", referrer: "https://mydomain/channels/plus4_allstars@stereo.kenobit.it"
but track exists here:
/webapp/funkwhale/site/data/media/federation_cache/tracks/dd/02/75/5tarbuck - Dungeon and Underground - Pets Rescue Soundtrack - Plus/4-all-stars.mp3
Note that nginx tries to access track with url-encoded path while the file is available as unencoded path.
What is expected?
Track plays
Context
It seems that playing a track from a federated instance when the track contains a space in path is not working due to difference on how the track is saved and retrieved.
Commenting the line https://dev.funkwhale.audio/funkwhale/funkwhale/-/blob/develop/api/funkwhale_api/music/views.py#L487 and trying again to play a track after restart leads to a working track playing.
Note: I don't have any clue about funkwhale behaviour and DB but I noticed that it may be necessary to remove the upload or the track from the DB before attempting to play it again after code change because it seems that somehow the track path on filesystem is saved the first time. If the path is wrong the track won't play regardless of code change, while if the track plays then it works regardless of the code change.
Funkwhale version(s) affected: 1.4.0rc2
Funkwhale installed from archive, using uwsgi + nginx mydomain.conf is nginx config