nr++;
}
- // move comments
+ // move comments, if any
nc=0;
if (src->listComments(di.id)) {
- if ((tgt->getCapabilities() & DNSBackend::CAP_COMMENTS) == 0) {
- throw PDNSException("Target backend does not support comments - remove them first");
- }
- Comment c; // NOLINT(readability-identifier-length)
- while(src->getComment(c)) {
- c.domain_id = di_new.id;
- if (!tgt->feedComment(c)) {
+ bool firstComment{true};
+ Comment comm;
+ while (src->getComment(comm)) {
+ if (firstComment) {
+ firstComment = false;
+ if ((tgt->getCapabilities() & DNSBackend::CAP_COMMENTS) == 0) {
+ // TODO: consider simply warning about comments not being copied, and
+ // skip them, rather than abort everything?
+ tgt->abortTransaction();
+ throw PDNSException("Target backend does not support comments - remove them first");
+ }
+ }
+ comm.domain_id = di_new.id;
+ if (!tgt->feedComment(comm)) {
+ tgt->abortTransaction();
throw PDNSException("Failed to feed zone comments");
}
nc++;