diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index 70f26019..1f88b8dd 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -144,11 +144,6 @@ namespace Exiv2 { copyExifToXmp(exifData_, xmpData_); copyIptcToXmp(iptcData_, xmpData_); - // #589 - restore tags which were modified by the convertors - for (auto&& it : copy) { - xmpData_[it.key()] = it.value(); - } - // #1112 - restore dates if they lost their TZ info for (auto&& date : dates_) { std::string sKey = date.first; @@ -163,6 +158,11 @@ namespace Exiv2 { } } + // #589 - restore tags which were modified by the convertors + for (auto&& it : copy) { + xmpData_[it.key()] = it.value(); + } + if (XmpParser::encode(xmpPacket_, xmpData_, XmpParser::omitPacketWrapper|XmpParser::useCompactFormat) > 1) { #ifndef SUPPRESS_WARNINGS diff --git a/test/data/issue_1998.xmp b/test/data/issue_1998.xmp new file mode 100644 index 00000000..c1b84fa4 --- /dev/null +++ b/test/data/issue_1998.xmp @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/tests/bugfixes/github/test_pr_1999.py b/tests/bugfixes/github/test_pr_1999.py new file mode 100644 index 00000000..ef6e4b64 --- /dev/null +++ b/tests/bugfixes/github/test_pr_1999.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +import system_tests +from system_tests import CaseMeta, path + +class TestXmpDateTimeSetting(metaclass=CaseMeta): + """ + Test fix for issue 1998. + """ + + infile = path("$data_path/issue_1998.xmp") + commands = [ + "$exiv2 -M\"set Xmp.xmp.CreateDate XmpText 2021-02-03T12:00:00+01:00\" $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + "$exiv2 -M\"set Xmp.xmp.CreateDate XmpText 2021-02-03T12:34:56+02:00\" $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + ] + stdout = [ + "", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:00:00+01:00 +""", + "", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:34:56+02:00 +""", + ] + stderr = [""]*4 + retval = [0]*4 +