about summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-12 14:09:34 -0400
committerJune McEnroe <june@causal.agency>2020-04-12 14:13:43 -0400
commit0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d (patch)
treeeddd00889239bf88eb495d1f31fa735257f9f320 /archive.c
parentDo not use <h1> for subject lines (diff)
downloadbubger-0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d.tar.gz
bubger-0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d.zip
Fetch and parse BODYSTRUCTURE
Diffstat (limited to 'archive.c')
-rw-r--r--archive.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/archive.c b/archive.c
index c84b74e..69d3c77 100644
--- a/archive.c
+++ b/archive.c
@@ -112,6 +112,7 @@ int main(int argc, char *argv[]) {
 		Concat,
 		Logout,
 	} state = Ready;
+	size_t exportTags = 0;
 
 	enum Atom login = atom("login");
 	enum Atom examine = atom("examine");
@@ -185,6 +186,7 @@ int main(int argc, char *argv[]) {
 				threads = resp.data;
 				resp.data = (struct List) {0};
 				if (exportFetch(imap, export, threads)) {
+					exportTags = 1;
 					state = Export;
 				} else {
 					concatFetch(imap, concat, threads);
@@ -195,9 +197,10 @@ int main(int argc, char *argv[]) {
 			break; case Export: {
 				if (resp.resp == AtomFetch) {
 					if (!resp.data.len) errx(EX_PROTOCOL, "missing FETCH data");
-					exportData(dataCheck(resp.data.ptr[0], List).list);
+					struct List items = dataCheck(resp.data.ptr[0], List).list;
+					if (exportData(imap, export, items)) exportTags++;
 				}
-				if (resp.tag != export) break;
+				if (resp.tag != export || --exportTags) break;
 				concatFetch(imap, concat, threads);
 				state = Concat;
 			}