summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--archive.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/archive.c b/archive.c
index 1ef4f33..91c6118 100644
--- a/archive.c
+++ b/archive.c
@@ -82,6 +82,7 @@ static void createDirs(void) {
 
 int main(int argc, char *argv[]) {
 	int exitStatus = 0;
+	bool truncate = false;
 
 	const char *host = NULL;
 	const char *port = "imaps";
@@ -95,7 +96,7 @@ int main(int argc, char *argv[]) {
 
 	for (
 		int opt;
-		0 < (opt = getopt(argc, argv, "C:H:S:a:h:im:p:qs:t:u:vw:y:"));
+		0 < (opt = getopt(argc, argv, "C:H:S:T:a:h:im:p:qs:tu:vw:y:"));
 	) {
 		switch (opt) {
 			break; case 'C': {
@@ -104,6 +105,7 @@ int main(int argc, char *argv[]) {
 			}
 			break; case 'H': concatHead = optarg;
 			break; case 'S': search = optarg;
+			break; case 'T': baseTitle = optarg;
 			break; case 'a': algo = optarg;
 			break; case 'h': host = optarg;
 			break; case 'i': idle = true;
@@ -111,7 +113,7 @@ int main(int argc, char *argv[]) {
 			break; case 'p': port = optarg;
 			break; case 'q': quiet = true; exitStatus = EXIT_FAILURE;
 			break; case 's': baseSubscribe = optarg;
-			break; case 't': baseTitle = optarg;
+			break; case 't': truncate = true;
 			break; case 'u': baseURL = optarg;
 			break; case 'v': imapVerbose = true;
 			break; case 'w': passPath = optarg;
@@ -177,7 +179,13 @@ int main(int argc, char *argv[]) {
 	for (; resp = respOk(imapResp(&imap)), resp.tag != login; respFree(resp));
 	respFree(resp);
 
-examine:;
+examine:
+	if (truncate) {
+		int error = ftruncate(STDOUT_FILENO, 0);
+		if (error) warn("ftruncate");
+		rewind(stdout);
+	}
+
 	uint32_t uidNext = 0;
 	uint32_t uidValidity = 0;
 	enum Atom examine = atom("examine");
@@ -259,6 +267,7 @@ concat:;
 
 	concatThreads(threads, envelopes);
 	concatIndex(threads, envelopes);
+	fflush(stdout);
 	uidWrite("UIDNEXT", uidNext);
 
 	for (size_t i = 0; i < threads.len; ++i) {
0'>2018-04-03Add ArcaJune McEnroe 2018-04-03Add new DMST and Joni VoidJune McEnroe 2018-04-03Add The Body LoversJune McEnroe 2018-04-03Add some albums from recentlyJune McEnroe 2018-04-03Add Saltland Light of MercyJune McEnroe 2018-04-03Add Jessica Moss GlaciersJune McEnroe 2018-04-03Add BNNY RBBTJune McEnroe 2018-04-03Add DepthsJune McEnroe 2018-04-03Add new Saltland previewJune McEnroe 2018-04-03Add BenjiJune McEnroe 2018-04-03Add Mouth MoodsJune McEnroe 2018-04-03Add Those Who Walk AwayJune McEnroe 2018-04-03Add Some TunesJune McEnroe 2018-04-03Add Pas pire popJune McEnroe 2018-04-03Add I Give You PowerJune McEnroe 2018-04-03Add Jenny GoGoJune McEnroe 2018-04-03Add KKB Fish BowlJune McEnroe 2018-04-03Add new Avec le soleil album previewJune McEnroe 2018-04-03Add Julien Baker as recent new musicJune McEnroe 2018-04-03Add recent new musicJune McEnroe