Fix #273: fix_track_files will now update files with bad mimetype

This commit is contained in:
Eliot Berriot 2018-06-03 18:57:35 +02:00
parent 390dcfd06f
commit 18ad6cfa78
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
3 changed files with 32 additions and 2 deletions

View file

@ -33,9 +33,9 @@ class Command(BaseCommand):
def fix_mimetypes(self, dry_run, **kwargs):
self.stdout.write('Fixing missing mimetypes...')
matching = models.TrackFile.objects.filter(
source__startswith='file://', mimetype=None)
source__startswith='file://').exclude(mimetype__startswith='audio/')
self.stdout.write(
'[mimetypes] {} entries found with no mimetype'.format(
'[mimetypes] {} entries found with bad or no mimetype'.format(
matching.count()))
for extension, mimetype in utils.EXTENSION_TO_MIMETYPE.items():
qs = matching.filter(source__endswith='.{}'.format(extension))