summary refs log tree commit diff
path: root/export.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-10 11:33:04 -0400
committerJune McEnroe <june@causal.agency>2020-04-10 11:33:04 -0400
commit5d2ea6d9d60a64579eb801a8e46ce7b65d1fbd1f (patch)
treea375f50c9594ba2ebb6195ab83a4845d817b764e /export.c
parentUse UIDNEXT to avoid asking IMAP to do any work (diff)
downloadbubger-5d2ea6d9d60a64579eb801a8e46ce7b65d1fbd1f.tar.gz
bubger-5d2ea6d9d60a64579eb801a8e46ce7b65d1fbd1f.zip
Link mbox files into message/
Diffstat (limited to '')
-rw-r--r--export.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/export.c b/export.c
index 3e87521..b1f63b8 100644
--- a/export.c
+++ b/export.c
@@ -34,6 +34,12 @@ static const char *uidPath(uint32_t uid, const char *type) {
 	return buf;
 }
 
+static const char *messagePath(const char *messageID, const char *type) {
+	static char buf[PATH_MAX];
+	snprintf(buf, sizeof(buf), "message/%s.%s", messageID, type);
+	return buf;
+}
+
 static void flatten(struct List *flat, struct List nested) {
 	for (size_t i = 0; i < nested.len; ++i) {
 		if (nested.ptr[i].type == List) {
@@ -253,6 +259,10 @@ void exportData(struct List items) {
 		|| fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
 
+	const char *dest = messagePath(envelope.messageID, "mbox");
+	error = link(path, dest);
+	if (error) err(EX_CANTCREAT, "%s", dest);
+
 	path = uidPath(uid, "html");
 	file = fopen(path, "w");
 	if (!file) err(EX_CANTCREAT, "%s", path);