api: Do not generate "track" into slugs

This commit is contained in:
Paul Bienkowski 2021-11-27 20:39:41 +01:00
parent 6ed9edf191
commit 9a13631097

View file

@ -226,10 +226,15 @@ class Track(Base):
return self.is_visible_to_private(user) or self.public return self.is_visible_to_private(user) or self.public
def generate_slug(self, new_title_or_filename=None): def generate_slug(self, new_title_or_filename=None):
input_text = ( input_text = new_title_or_filename or self.title or self.original_file_name
new_title_or_filename or self.title or self.original_file_name or "track"
) if input_text is not None:
self.slug = slugify(input_text, separator="_") + "-" + random_string(6) self.slug = slugify(input_text, separator="_") + "-"
else:
self.slug = ""
# make unique
self.slug += random_string(8)
async def prevent_duplicates(self, session, file_body): async def prevent_duplicates(self, session, file_body):
hex_hash = hashlib.sha512(file_body).hexdigest() hex_hash = hashlib.sha512(file_body).hexdigest()