Skip to content

Commit ed96941

Browse files
committed
mt2exm: avoid emitting eml files when source message has no RFC5322 representation
Fixes: gromox-2.48-14-g468c9b5c6 References: DESK-4124
1 parent 8269f95 commit ed96941

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tools/mt2exm.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,20 @@ static int exm_create_msg(uint64_t parent_fld, MESSAGE_CONTENT *ctnt,
411411
* does away with the issue of multiple processes trying to potentially
412412
* vivify the same filename-derived-from-same-content.
413413
*/
414-
char guidtxt[GUIDSTR_SIZE]{};
415-
GUID::random_new().to_str(guidtxt, std::size(guidtxt), 32);
416-
auto midstr = fmt::format("R-{}/{}", &guidtxt[30], guidtxt);
417-
digest["file"] = midstr;
418-
if (!exmdb_client->imapfile_write(g_storedir, "eml",
419-
midstr.c_str(), im_repr.c_str())) {
420-
fprintf(stderr, "exm: imapfile_write RPC failed\n");
421-
return -EIO;
414+
std::string djson;
415+
if (im_repr.size() > 0) {
416+
char guidtxt[GUIDSTR_SIZE]{};
417+
GUID::random_new().to_str(guidtxt, std::size(guidtxt), 32);
418+
auto midstr = fmt::format("R-{}/{}", &guidtxt[30], guidtxt);
419+
digest["file"] = midstr;
420+
if (!exmdb_client->imapfile_write(g_storedir, "eml",
421+
midstr.c_str(), im_repr.c_str())) {
422+
fprintf(stderr, "exm: imapfile_write RPC failed\n");
423+
return -EIO;
424+
}
425+
djson = json_to_str(digest);
426+
digest.removeMember("file");
422427
}
423-
auto djson = json_to_str(digest);
424-
digest.removeMember("file");
425428

426429
uint64_t outmid = 0, outcn = 0;
427430
if (!exmdb_client->write_message(g_storedir, CP_UTF8, parent_fld,

0 commit comments

Comments
 (0)