changeset 1987:3b1f8ed213ca HEAD

maildir: don't use ".temp" prefix for temporary files, since in ~/Maildir they conflict with mailbox namespace.
author Timo Sirainen <tss@iki.fi>
date Mon, 10 May 2004 02:32:43 +0300
parents 7ac0ef106427
children 739b469b99e2
files src/lib-storage/index/index-storage.h src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/maildir/maildir-uidlist.c src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/subscription-file/subscription-file.c src/lib-storage/subscription-file/subscription-file.h
diffstat 6 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-storage.h	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/index/index-storage.h	Mon May 10 02:32:43 2004 +0300
@@ -42,6 +42,7 @@
 	char *index_dir;
 	char *control_dir;
 	char *inbox_path; /* INBOX location */
+        char *temp_prefix; /* prefix for temporary files */
 
 	char *user; /* name of user accessing the storage */
 
--- a/src/lib-storage/index/maildir/maildir-storage.c	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Mon May 10 02:32:43 2004 +0300
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002-2003 Timo Sirainen */
 
 #include "lib.h"
+#include "hostpid.h"
 #include "home-expand.h"
 #include "mkdir-parents.h"
 #include "unlink-directory.h"
@@ -92,6 +93,10 @@
 		storage->storage.hierarchy_sep = hierarchy_sep;
 	storage->storage.namespace = i_strdup(namespace);
 
+	/* the default ".temp.xxx" prefix would be treated as directory */
+	storage->temp_prefix =
+		i_strconcat("temp.", my_hostname, ".", my_pid, ".", NULL);
+
 	storage->dir = i_strdup(home_expand(root_dir));
 	storage->inbox_path = i_strdup(home_expand(inbox_dir));
 	storage->index_dir = i_strdup(home_expand(index_dir));
@@ -108,6 +113,7 @@
 
 	index_storage_deinit(storage);
 
+	i_free(storage->temp_prefix);
 	i_free(storage->dir);
 	i_free(storage->inbox_path);
 	i_free(storage->index_dir);
@@ -731,7 +737,8 @@
 			   "/" SUBSCRIPTION_FILE_NAME, NULL);
 
 	name = maildir_fix_mailbox_name(storage, name, FALSE);
-	return subsfile_set_subscribed(_storage, path, name, set);
+	return subsfile_set_subscribed(_storage, path, storage->temp_prefix,
+				       name, set);
 }
 
 static int maildir_get_mailbox_name_status(struct mail_storage *_storage,
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Mon May 10 02:32:43 2004 +0300
@@ -79,8 +79,9 @@
 	path = t_strconcat(uidlist->ibox->control_dir,
 			   "/" MAILDIR_UIDLIST_NAME, NULL);
         old_mask = umask(0777 & ~uidlist->ibox->mail_create_mode);
-	fd = file_dotlock_open(path, NULL, NULL, 0, 0,
-			       UIDLIST_LOCK_STALE_TIMEOUT, NULL, NULL);
+	fd = file_dotlock_open(path, uidlist->ibox->storage->temp_prefix,
+			       NULL, 0, 0, UIDLIST_LOCK_STALE_TIMEOUT,
+			       NULL, NULL);
 	umask(old_mask);
 	if (fd == -1) {
 		if (errno == EAGAIN)
--- a/src/lib-storage/index/mbox/mbox-storage.c	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Mon May 10 02:32:43 2004 +0300
@@ -728,7 +728,8 @@
 
 	path = t_strconcat(storage->dir, "/" SUBSCRIPTION_FILE_NAME, NULL);
 	name = mbox_fix_mailbox_name(storage, name, FALSE);
-	return subsfile_set_subscribed(_storage, path, name, set);
+	return subsfile_set_subscribed(_storage, path, storage->temp_prefix,
+				       name, set);
 }
 
 static int mbox_get_mailbox_name_status(struct mail_storage *_storage,
--- a/src/lib-storage/subscription-file/subscription-file.c	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/subscription-file/subscription-file.c	Mon May 10 02:32:43 2004 +0300
@@ -68,7 +68,7 @@
 }
 
 int subsfile_set_subscribed(struct mail_storage *storage, const char *path,
-			    const char *name, int set)
+			    const char *temp_prefix, const char *name, int set)
 {
 	const char *line;
 	struct istream *input;
@@ -79,7 +79,7 @@
 		name = "INBOX";
 
 	/* FIXME: set lock notification callback */
-	fd_out = file_dotlock_open(path, NULL, NULL,
+	fd_out = file_dotlock_open(path, temp_prefix, NULL,
 				   SUBSCRIPTION_FILE_LOCK_TIMEOUT,
 				   SUBSCRIPTION_FILE_CHANGE_TIMEOUT,
 				   SUBSCRIPTION_FILE_IMMEDIATE_TIMEOUT,
--- a/src/lib-storage/subscription-file/subscription-file.h	Mon May 10 02:21:28 2004 +0300
+++ b/src/lib-storage/subscription-file/subscription-file.h	Mon May 10 02:32:43 2004 +0300
@@ -14,6 +14,6 @@
 const char *subsfile_list_next(struct subsfile_list_context *ctx);
 
 int subsfile_set_subscribed(struct mail_storage *storage, const char *path,
-			    const char *name, int set);
+			    const char *temp_prefix, const char *name, int set);
 
 #endif