]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Added path parameter to mail_index_create_tmp_file()
authorTimo Sirainen <tss@iki.fi>
Tue, 7 Oct 2014 16:04:36 +0000 (19:04 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 7 Oct 2014 16:04:36 +0000 (19:04 +0300)
This allows using it for creating any kind of a new index file with proper
file permissions.

Some of the old code should probably be changed to use this. Maybe even move
this function to public mail-index.h

src/lib-index/mail-index-private.h
src/lib-index/mail-index-write.c
src/lib-index/mail-index.c

index b6877f0386882b51fd880aac93c9231383594fd3..6360791397128bf86a1b28044ff414972dbf0701 100644 (file)
@@ -259,7 +259,8 @@ void mail_index_register_sync_lost_handler(struct mail_index *index,
 void mail_index_unregister_sync_lost_handler(struct mail_index *index,
                                        mail_index_sync_lost_handler_t *cb);
 
-int mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
+int mail_index_create_tmp_file(struct mail_index *index,
+                              const char *path_prefix, const char **path_r);
 
 int mail_index_try_open_only(struct mail_index *index);
 void mail_index_close_file(struct mail_index *index);
index b3e0c9a4597b721d9e038338febb492e60320105..f90ee4efda8bf47a69c1e4b6e9bf6a5056996266 100644 (file)
@@ -68,7 +68,7 @@ static int mail_index_recreate(struct mail_index *index)
        i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
        i_assert(map->hdr.indexid == index->indexid);
 
-       fd = mail_index_create_tmp_file(index, &path);
+       fd = mail_index_create_tmp_file(index, index->filepath, &path);
        if (fd == -1)
                return -1;
 
index c8430d1273974df8bcf5e589c732fee07a76b70d..16b56d2197f2895346e42bcf061b41a833b367b1 100644 (file)
@@ -438,7 +438,8 @@ mail_index_try_open(struct mail_index *index)
        return ret;
 }
 
-int mail_index_create_tmp_file(struct mail_index *index, const char **path_r)
+int mail_index_create_tmp_file(struct mail_index *index,
+                              const char *path_prefix, const char **path_r)
 {
         mode_t old_mask;
        const char *path;
@@ -446,7 +447,7 @@ int mail_index_create_tmp_file(struct mail_index *index, const char **path_r)
 
        i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
 
-       path = *path_r = t_strconcat(index->filepath, ".tmp", NULL);
+       path = *path_r = t_strconcat(path_prefix, ".tmp", NULL);
        old_mask = umask(0);
        fd = open(path, O_RDWR|O_CREAT|O_EXCL, index->mode);
        umask(old_mask);