summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
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;
 			}