summary refs log tree commit diff
path: root/concat.c
diff options
context:
space:
mode:
Diffstat (limited to 'concat.c')
-rw-r--r--concat.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/concat.c b/concat.c
index eeab073..45ce12d 100644
--- a/concat.c
+++ b/concat.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sysexits.h>
+#include <unistd.h>
 
 #include "archive.h"
 #include "imap.h"
@@ -116,7 +117,12 @@ void concatData(struct List threads, struct List items) {
 
 	path = threadPath(envelope.messageID, "mbox");
 	error = stat(path, &file);
-	if (error || file.st_mtime < uidNewest(flat, "mbox")) {
+	if (error && flat.len == 1) {
+		uint32_t uid = dataCheck(flat.ptr[0], Number).number;
+		error = link(uidPath(uid, "mbox"), path);
+		if (error) err(EX_CANTCREAT, "%s", path);
+
+	} else if (error || file.st_mtime < uidNewest(flat, "mbox")) {
 		FILE *mbox = fopen(path, "w");
 		if (!mbox) err(EX_CANTCREAT, "%s", path);