mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-06 16:44:06 +00:00
PICARD-1892: Fixed deleting totaldiscs / totaltracks from Vorbis tags
Deleting failed if the file only contained disctotal or tracktotal tags, but not also totaldiscs or totaltracks.
This commit is contained in:
@@ -327,7 +327,7 @@ class VCommentFile(File):
|
||||
existing_tags.remove(item)
|
||||
tags[real_name] = existing_tags
|
||||
else:
|
||||
if tag in ('totaldiscs', 'totaltracks'):
|
||||
if tag in ('totaldiscs', 'totaltracks') and tag in tags:
|
||||
# both tag and real_name are to be deleted in this case
|
||||
del tags[tag]
|
||||
del tags[real_name]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Picard, the next-generation MusicBrainz tagger
|
||||
#
|
||||
# Copyright (C) 2019 Philipp Wolfer
|
||||
# Copyright (C) 2019-2020 Philipp Wolfer
|
||||
# Copyright (C) 2020 Laurent Monin
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
@@ -156,6 +156,24 @@ class CommonVorbisTests:
|
||||
self.assertTrue(self.format.supports_tag('lyrics:foó'))
|
||||
self.assertTrue(self.format.supports_tag('comment:foó'))
|
||||
|
||||
@skipUnlessTestfile
|
||||
def test_delete_totaldiscs_totaltracks(self):
|
||||
# Create a test file that contains only disctotal / tracktotal,
|
||||
# but not totaldiscs and totaltracks
|
||||
save_raw(self.filename, {
|
||||
'disctotal': '3',
|
||||
'tracktotal': '2',
|
||||
})
|
||||
metadata = Metadata()
|
||||
del metadata['totaldiscs']
|
||||
del metadata['totaltracks']
|
||||
save_metadata(self.filename, metadata)
|
||||
loaded_metadata = load_raw(self.filename)
|
||||
self.assertNotIn('disctotal', loaded_metadata)
|
||||
self.assertNotIn('totaldiscs', loaded_metadata)
|
||||
self.assertNotIn('tracktotal', loaded_metadata)
|
||||
self.assertNotIn('totaltracks', loaded_metadata)
|
||||
|
||||
|
||||
class FLACTest(CommonVorbisTests.VorbisTestCase):
|
||||
testfile = 'test.flac'
|
||||
|
||||
Reference in New Issue
Block a user