Mercurial > dovecot > core-2.2
changeset 473:cb7f34709d2d HEAD
Hardlink COPYing still copied the file name instead of generating a new one,
which really broke things when mail was duplicated in the same mailbox.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 21 Oct 2002 03:24:54 +0300 |
parents | 2fa0bfb65268 |
children | 47d0c169bdba |
files | src/lib-storage/index/maildir/maildir-copy.c src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-storage.h |
diffstat | 3 files changed, 16 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-copy.c Mon Oct 21 03:09:29 2002 +0300 +++ b/src/lib-storage/index/maildir/maildir-copy.c Mon Oct 21 03:24:54 2002 +0300 @@ -34,7 +34,8 @@ fname = index->lookup_field(index, rec, FIELD_TYPE_LOCATION); i_snprintf(src, sizeof(src), "%s/cur/%s", index->dir, fname); - fname = maildir_filename_set_flags(fname, flags); + fname = maildir_filename_set_flags(maildir_generate_tmp_filename(), + flags); i_snprintf(dest, sizeof(dest), "%s/new/%s", ctx->dest->index->dir, fname); @@ -62,10 +63,6 @@ if (!src->index->set_lock(src->index, MAIL_LOCK_SHARED)) return mail_storage_set_index_error(src); - if (!dest->index->set_lock(dest->index, MAIL_LOCK_EXCLUSIVE)) { - (void)src->index->set_lock(src->index, MAIL_LOCK_UNLOCK); - return mail_storage_set_index_error(dest); - } ctx.storage = src->box.storage; ctx.dest = dest; @@ -75,9 +72,6 @@ ret = index_messageset_foreach(src, messageset, uidset, copy_hard_func, &ctx); - if (!dest->index->set_lock(dest->index, MAIL_LOCK_UNLOCK)) - mail_storage_set_index_error(dest); - if (!src->index->set_lock(src->index, MAIL_LOCK_UNLOCK)) mail_storage_set_index_error(src);
--- a/src/lib-storage/index/maildir/maildir-save.c Mon Oct 21 03:09:29 2002 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Mon Oct 21 03:24:54 2002 +0300 @@ -12,17 +12,23 @@ #include <fcntl.h> #include <utime.h> +const char *maildir_generate_tmp_filename(void) +{ + static unsigned int create_count = 0; + + hostpid_init(); + + return t_strdup_printf("%lu.%s_%u.%s", (unsigned long) ioloop_time, + my_pid, create_count++, my_hostname); +} + static int maildir_create_tmp(MailStorage *storage, const char *dir, const char **fname) { - static unsigned int create_count = 0; const char *path; int fd; - hostpid_init(); - - *fname = t_strdup_printf("%lu.%s_%u.%s", (unsigned long) ioloop_time, - my_pid, create_count++, my_hostname); + *fname = maildir_generate_tmp_filename(); path = t_strconcat(dir, "/", *fname, NULL); fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0660);
--- a/src/lib-storage/index/maildir/maildir-storage.h Mon Oct 21 03:09:29 2002 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.h Mon Oct 21 03:24:54 2002 +0300 @@ -16,4 +16,7 @@ int maildir_expunge_locked(IndexMailbox *ibox, int notify); +/* Return new filename base to save into tmp/ */ +const char *maildir_generate_tmp_filename(void); + #endif