From 67721f3dbd4ffeb1a03145170df40f616ee0a118 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 25 Apr 2020 14:22:41 -0400 Subject: Accumulate thread envelopes before concatenation --- archive.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'archive.c') diff --git a/archive.c b/archive.c index 64b234e..af0329a 100644 --- a/archive.c +++ b/archive.c @@ -123,6 +123,7 @@ int main(int argc, char *argv[]) { uint32_t uidNext = 0; struct List threads = {0}; + struct Envelope *envelopes = NULL; for (struct Resp resp; resp = imapResp(imapRead), resp.resp != AtomBye;) { if (resp.resp == AtomNo || resp.resp == AtomBad) { errx(EX_CONFIG, "%s %s", Atoms[resp.resp], resp.text); @@ -184,8 +185,12 @@ int main(int argc, char *argv[]) { createDir("attachment"); createDir("message"); createDir("thread"); + threads = resp.data; resp.data = (struct List) {0}; + envelopes = calloc(threads.len, sizeof(*envelopes)); + if (!envelopes) err(EX_OSERR, "calloc"); + if (exportFetch(imap, export, threads)) { exportTags = 1; state = Export; @@ -209,9 +214,12 @@ int main(int argc, char *argv[]) { break; case Concat: { if (resp.resp == AtomFetch) { if (!resp.data.len) errx(EX_PROTOCOL, "missing FETCH data"); - concatData(threads, dataCheck(resp.data.ptr[0], List).list); + struct Data items = dataTake(&resp.data.ptr[0]); + concatData(threads, envelopes, dataCheck(items, List).list); } if (resp.tag != concat) break; + concatThreads(threads, envelopes); + concatIndex(threads, envelopes); uidWrite("UIDNEXT", uidNext); fprintf(imap, "ayy LOGOUT\r\n"); state = Logout; -- cgit 1.4.1