[dovecot-cvs] dovecot/src/lib-storage/index index-copy.c,1.20,1.21 index-storage.h,1.21,1.22
cras at procontrol.fi
cras at procontrol.fi
Wed Nov 20 20:31:17 EET 2002
Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv21212
Modified Files:
index-copy.c index-storage.h
Log Message:
COPYing inside same mailbox works now with mbox. Also fixed SAVE leaving
From-line written to mbox file if it was aborted.
Index: index-copy.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-copy.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- index-copy.c 4 Nov 2002 04:47:40 -0000 1.20
+++ index-copy.c 20 Nov 2002 18:31:15 -0000 1.21
@@ -11,6 +11,7 @@
typedef struct {
Mailbox *dest;
const char **custom_flags;
+ int copy_inside_mailbox;
} CopyContext;
static int copy_func(MailIndex *index, MailIndexRecord *rec,
@@ -18,6 +19,7 @@
unsigned int idx_seq __attr_unused__, void *context)
{
CopyContext *ctx = context;
+ IndexMailbox *dest_ibox = NULL;
IBuffer *inbuf;
time_t internal_date;
int failed, deleted;
@@ -26,10 +28,19 @@
if (inbuf == NULL)
return FALSE;
+ if (ctx->copy_inside_mailbox) {
+ /* kludgy.. */
+ dest_ibox = (IndexMailbox *) ctx->dest;
+ dest_ibox->delay_save_unlocking = TRUE;
+ }
+
/* save it in destination mailbox */
failed = !ctx->dest->save(ctx->dest, rec->msg_flags,
ctx->custom_flags, internal_date, 0,
- inbuf, inbuf->v_size);
+ inbuf, inbuf->v_limit);
+
+ if (ctx->copy_inside_mailbox)
+ dest_ibox->delay_save_unlocking = FALSE;
i_buffer_unref(inbuf);
return !failed;
@@ -49,9 +60,19 @@
return FALSE;
}
- lock_type = destbox->storage == box->storage &&
- strcmp(destbox->name, box->name) == 0 ?
- MAIL_LOCK_EXCLUSIVE : MAIL_LOCK_SHARED;
+ ctx.copy_inside_mailbox =
+ destbox->storage == box->storage &&
+ strcmp(destbox->name, box->name) == 0;
+
+ if (ctx.copy_inside_mailbox) {
+ /* copying inside same mailbox */
+ if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
+ return mail_storage_set_index_error(ibox);
+
+ lock_type = MAIL_LOCK_EXCLUSIVE;
+ } else {
+ lock_type = MAIL_LOCK_SHARED;
+ }
if (!index_storage_sync_and_lock(ibox, TRUE, lock_type))
return FALSE;
Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- index-storage.h 12 Nov 2002 05:27:30 -0000 1.21
+++ index-storage.h 20 Nov 2002 18:31:15 -0000 1.22
@@ -28,6 +28,7 @@
unsigned int synced_messages_count;
unsigned int sent_diskspace_warning:1;
+ unsigned int delay_save_unlocking:1; /* For COPYing inside mailbox */
};
extern ImapMessageCacheIface index_msgcache_iface;
More information about the dovecot-cvs
mailing list