mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 21:14:23 -04:00
Consistently handle invalid and deprecated tags in setProperties()
This commit reverts the use of strip() in setProperties() because the latter function should not change the file before save() is called. Instead, the following policy is now consistently applied for file formats with multiple tag types: - the recommended tag type is created, if it does not exist - deprecated tags are updated, if they exist, but not created - illegal tag types are ignored by setProperties(), but used in properties() if no others exist. The only tag types considered "illegal" so far are APEv2 in MPEG and ID3 in FLAC.
This commit is contained in:
@ -132,7 +132,7 @@ void APE::File::removeUnsupportedProperties(const StringList &properties)
|
||||
PropertyMap APE::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(d->hasID3v1)
|
||||
strip(ID3v1);
|
||||
d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
|
||||
return d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,7 @@ namespace TagLib {
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Creates an APEv2 tag if necessary. A pontentially existing ID3v1
|
||||
* tag is considered deprecated and will be removed, invalidating all
|
||||
* pointers to that tag.
|
||||
* tag will be updated as well.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
|
||||
|
@ -168,10 +168,6 @@ void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
|
||||
|
||||
PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(d->hasID3v1)
|
||||
d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
|
||||
if(d->hasID3v2)
|
||||
d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
|
||||
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,8 @@ namespace TagLib {
|
||||
* Implements the unified property interface -- import function.
|
||||
* This always creates a Xiph comment, if none exists. The return value
|
||||
* relates to the Xiph comment only.
|
||||
* Potential ID3v1 and ID3v2 tags will also be updated.
|
||||
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed
|
||||
* in the FLAC specification.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
|
||||
|
@ -136,7 +136,7 @@ void MPC::File::removeUnsupportedProperties(const StringList &properties)
|
||||
PropertyMap MPC::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(d->hasID3v1)
|
||||
strip(ID3v1);
|
||||
d->tag.access<APE::Tag>(MPCID3v1Index, false)->setProperties(properties);
|
||||
return d->tag.access<APE::Tag>(MPCAPEIndex, true)->setProperties(properties);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace TagLib {
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Affects only the APEv2 tag which will be created if necessary.
|
||||
* If an ID3v1 tag exists, it will be stripped from the file.
|
||||
* If an ID3v1 tag exists, it will be updated as well.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap &);
|
||||
|
||||
|
@ -159,8 +159,6 @@ void MPEG::File::removeUnsupportedProperties(const StringList &properties)
|
||||
|
||||
PropertyMap MPEG::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(d->hasAPE)
|
||||
strip(APE, true);
|
||||
if(d->hasID3v1)
|
||||
// update ID3v1 tag if it exists, but ignore the return value
|
||||
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
|
||||
|
@ -145,9 +145,7 @@ namespace TagLib {
|
||||
/*!
|
||||
* Implements the writing part of the unified tag dictionary interface.
|
||||
* In order to avoid problems with deprecated tag formats, this method
|
||||
* always creates an ID3v2 tag if necessary, and removes potential APEv2
|
||||
* tags (also invalidating all pointers to the APE tag) which are
|
||||
* considered bad practice in MP3 files.
|
||||
* always creates an ID3v2 tag if necessary.
|
||||
* If an ID3v1 tag exists, it will be updated as well, within the
|
||||
* limitations of that format.
|
||||
* The returned PropertyMap refers to the ID3v2 tag only.
|
||||
|
@ -120,7 +120,7 @@ PropertyMap WavPack::File::properties() const
|
||||
PropertyMap WavPack::File::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
if(d->hasID3v1)
|
||||
strip(ID3v1);
|
||||
d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
|
||||
return d->tag.access<APE::Tag>(WavAPEIndex, true)->setProperties(properties);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ namespace TagLib {
|
||||
/*!
|
||||
* Implements the unified property interface -- import function.
|
||||
* Creates an APE tag if it does not exists and calls setProperties() on
|
||||
* that. Any existing ID3v1 tag will be removed.
|
||||
* that. Any existing ID3v1 tag will be updated as well.
|
||||
*/
|
||||
PropertyMap setProperties(const PropertyMap&);
|
||||
|
||||
|
Reference in New Issue
Block a user