about summary refs log tree commit diff
path: root/concat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-10 17:42:19 -0400
committerJune McEnroe <june@causal.agency>2020-04-10 17:42:19 -0400
commit71d7aada572a6c2751d82f45869006c8a7be72c1 (patch)
tree001f9c504ade6d1db2a7ac7d50a5f0b5d73c20ec /concat.c
parentConcatenate Atom threads (diff)
downloadbubger-71d7aada572a6c2751d82f45869006c8a7be72c1.tar.gz
bubger-71d7aada572a6c2751d82f45869006c8a7be72c1.zip
Use hard links for single-message mbox threads
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);