summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-10 13:16:38 -0400
committerJune McEnroe <june@causal.agency>2020-04-10 13:16:38 -0400
commitcc641ff33aa6421efc0ae84cfdfc61251406c2df (patch)
tree15f7a31179f41f018662d2fe0f18b449d41c47df /archive.c
parentRename exportThreads to exportFetch (diff)
downloadbubger-cc641ff33aa6421efc0ae84cfdfc61251406c2df.tar.gz
bubger-cc641ff33aa6421efc0ae84cfdfc61251406c2df.zip
Fetch thread root envelopes for concat
Diffstat (limited to '')
-rw-r--r--archive.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/archive.c b/archive.c
index ea2259c..c2e7f5c 100644
--- a/archive.c
+++ b/archive.c
@@ -103,11 +103,14 @@ int main(int argc, char *argv[]) {
 		if (!pass) errx(EX_CONFIG, ENV_PASSWORD " unset");
 	}
 
-	uint32_t uidNext = 0;
 	enum Atom login = 0;
 	enum Atom examine = atom("EXAMINE");
 	enum Atom thread = atom("THREAD");
 	enum Atom export = 0;
+	enum Atom concat = 0;
+
+	uint32_t uidNext = 0;
+	struct List threads = {0};
 
 	FILE *imap = imapOpen(host, port);
 	for (struct Resp resp; resp = imapResp(imap), resp.resp != AtomBye;) {
@@ -172,7 +175,10 @@ int main(int argc, char *argv[]) {
 			}
 			createDir("UID");
 			createDir("message");
-			export = exportFetch(imap, resp.data);
+			threads = resp.data;
+			resp.data = (struct List) {0};
+			export = exportFetch(imap, threads);
+			if (!export) concat = concatFetch(imap, threads);
 		}
 
 		if (export && resp.resp == AtomFetch) {
@@ -182,6 +188,11 @@ int main(int argc, char *argv[]) {
 			exportData(resp.data.ptr[0].list);
 		}
 
+		if (export && resp.tag == export) {
+			export = 0;
+			concat = concatFetch(imap, threads);
+		}
+
 		respFree(resp);
 	}
 	fclose(imap);