Verified Commit 0c8f4400 authored by Blopware's avatar Blopware Committed by Georg Krause
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 33f79934
...@@ -75,11 +75,15 @@ def set_query_parameter(url, **kwargs): ...@@ -75,11 +75,15 @@ def set_query_parameter(url, **kwargs):
@deconstructible @deconstructible
class ChunkedPath(object): class ChunkedPath(object):
def sanitize_filename(self, filename):
return filename.replace("/", "-")
def __init__(self, root, preserve_file_name=True): def __init__(self, root, preserve_file_name=True):
self.root = root self.root = root
self.preserve_file_name = preserve_file_name self.preserve_file_name = preserve_file_name
def __call__(self, instance, filename): def __call__(self, instance, filename):
self.sanitize_filename(filename)
uid = str(uuid.uuid4()) uid = str(uuid.uuid4())
chunk_size = 2 chunk_size = 2
chunks = [uid[i : i + chunk_size] for i in range(0, len(uid), chunk_size)] chunks = [uid[i : i + chunk_size] for i in range(0, len(uid), chunk_size)]
......
Sanitize remote tracks' saving locations with slashes on their names (#1435)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment