mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
Don't duplicate from ID3v1 to ID3v2 when saving only ID3v2
When saving only v2 with stripOthers (which means stripping v1), the data from v1 would still be duplicated to v2. Likewise for the other way around. This is not the expected outcome when e.g. a frame was removed in v2, because it would be added again on save from the v1 data. The test shows that. This changes save to only duplicate the data when the other tag type will not be stripped.
This commit is contained in:
@ -71,6 +71,7 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
|
||||
CPPUNIT_TEST(testPropertyInterface);
|
||||
CPPUNIT_TEST(testPropertyInterface2);
|
||||
CPPUNIT_TEST(testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -628,6 +629,28 @@ public:
|
||||
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
|
||||
}
|
||||
|
||||
void testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2()
|
||||
{
|
||||
ScopedFileCopy copy("xing", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
{
|
||||
MPEG::File foo(newname.c_str());
|
||||
foo.tag()->setArtist("Artist");
|
||||
foo.save(MPEG::File::ID3v1 | MPEG::File::ID3v2);
|
||||
}
|
||||
|
||||
{
|
||||
MPEG::File bar(newname.c_str());
|
||||
bar.ID3v2Tag()->removeFrames("TPE1");
|
||||
// Should strip ID3v1 here and not add old values to ID3v2 again
|
||||
bar.save(MPEG::File::ID3v2, true);
|
||||
}
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TPE1"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);
|
||||
|
Reference in New Issue
Block a user