Skip to content
Snippets Groups Projects
Commit a3504ae9 authored by Blopware's avatar Blopware Committed by blopware
Browse files

Sanitize remote tracks' saving locations with slashes on their names

For that case, the resulting saved file made use of these slashes to
store the tracks in subdirectories of federation_cache/xx/xx/xx, instead of
in the federation_cache/xx/xx/xx directory itself. As a consequence, the
tracks are downloaded in the wrong location, and upon any trial of
playing the tracks, funkwhale responds with the message
"The track cannot be loaded. You can have connectivity issues"

An example of a podcast with this kind of RSS items is located in
https://www.rtve.es/api/programas/2082/audios.rss

This commit overcomes this by a simple replacement of the offending
slashes to hyphens.
parent b26481a5
Branches
No related tags found
No related merge requests found
Pipeline #14186 failed
...@@ -688,6 +688,8 @@ TRACK_FILE_IMPORT_STATUS_CHOICES = ( ...@@ -688,6 +688,8 @@ TRACK_FILE_IMPORT_STATUS_CHOICES = (
("skipped", "Skipped"), ("skipped", "Skipped"),
) )
def sanitize_remote_location_path(filename):
return filename.replace("/", "-")
def get_file_path(instance, filename): def get_file_path(instance, filename):
if isinstance(instance, UploadVersion): if isinstance(instance, UploadVersion):
...@@ -696,6 +698,7 @@ def get_file_path(instance, filename): ...@@ -696,6 +698,7 @@ def get_file_path(instance, filename):
if instance.library.actor.get_user(): if instance.library.actor.get_user():
return common_utils.ChunkedPath("tracks")(instance, filename) return common_utils.ChunkedPath("tracks")(instance, filename)
else: else:
filename = sanitize_remote_location_path(filename)
# we cache remote tracks in a different directory # we cache remote tracks in a different directory
return common_utils.ChunkedPath("federation_cache/tracks")(instance, filename) return common_utils.ChunkedPath("federation_cache/tracks")(instance, filename)
......
Sanitize remote tracks' saving locations with slashes on their names (#1435)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment