From 0e36eec6c76084fca1b6fc560abe5b29bd585502 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 3 May 2023 21:00:59 +0200 Subject: [PATCH] Suppress "field not supported" for ID3v1 fields if writing ID3v2 as well --- cli/mainfeatures.cpp | 7 +++++-- tests/cli.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/mainfeatures.cpp b/cli/mainfeatures.cpp index 2973256..48e8528 100644 --- a/cli/mainfeatures.cpp +++ b/cli/mainfeatures.cpp @@ -675,6 +675,7 @@ void setTagInfo(const SetTagInfoArgs &args) diag.emplace_back(DiagLevel::Critical, "Can not create appropriate tags for file.", context); } else { // iterate through all tags + const auto willWriteAnId3v2Tag = fileInfo.hasId3v2Tag(); for (auto *tag : tags) { // clear current values if option is present if (args.removeOtherFieldsArg.isPresent()) { @@ -781,10 +782,12 @@ void setTagInfo(const SetTagInfoArgs &args) argsToString("An IO error occurred when parsing the specified file \"", path, "\": ", e.what()), context); } } - // finally set the values + // finally set/clear the values try { + // add error if field is not supported unless it is just ID3v1 and we are writing an ID3v2 tag as well if ((!convertedValues.empty() || convertedId3v2CoverValues.empty()) - && !denotedScope.field.setValues(tag, tagType, convertedValues)) { + && !denotedScope.field.setValues(tag, tagType, convertedValues) + && (tagType != TagType::Id3v1Tag || !willWriteAnId3v2Tag)) { diag.emplace_back(DiagLevel::Critical, argsToString("Unable set field \"", denotedScope.field.name(), "\": setting field is not supported"), context); } diff --git a/tests/cli.cpp b/tests/cli.cpp index dbf952c..db23752 100644 --- a/tests/cli.cpp +++ b/tests/cli.cpp @@ -259,7 +259,7 @@ void CliTests::testModifyingCover() const auto lyrics = "lyrics>=" + lyricsFile; const char *const args1[] = { "tageditor", "get", "-f", mp3File1.data(), nullptr }; const char *const args2[] = { "tageditor", "set", otherCover.data(), frontCover0.data(), frontCover1.data(), backCover0.data(), lyrics.data(), - "-f", mp3File1.data(), nullptr }; + "--pedantic", "-f", mp3File1.data(), nullptr }; CPPUNIT_ASSERT_EQUAL(0, execApp(args2, stdout, stderr)); CPPUNIT_ASSERT_EQUAL(0, execApp(args1, stdout, stderr)); CPPUNIT_ASSERT_MESSAGE("covers added",