maildir-copy.c revision e1ca7af110ea6eeb6303bdd8f07c172b11dff2fa
/* Copyright (C) 2002-2004 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "maildir-storage.h"
#include "maildir-uidlist.h"
#include "maildir-keywords.h"
#include "index-mail.h"
#include "mail-copy.h"
#include <stdlib.h>
#include <unistd.h>
struct maildir_copy_context {
struct maildir_mailbox *mbox;
int hardlink;
struct maildir_uidlist_sync_ctx *uidlist_sync_ctx;
};
struct hardlink_ctx {
const char *dest_path;
int found;
};
struct rollback {
const char *fname;
};
void *context)
{
return 0;
"Not enough disk space");
return -1;
}
return 1;
"link(%s, %s) failed: %m",
return -1;
}
return 1;
}
static int
struct maildir_copy_context *ctx)
{
struct maildir_mailbox *src_mbox =
struct hardlink_ctx do_ctx;
const char *dest_fname;
unsigned int keywords_count;
if (keywords_count > 0) {
/* uidlist must be locked while accessing
keywords files */
&ctx->uidlist_sync_ctx) <= 0) {
/* error or timeout */
return -1;
}
}
}
flags &= ~MAIL_RECENT;
flags |= MAIL_RECENT;
keywords_count != 0 ?
&keywords_arr : NULL);
else
do_hardlink, &do_ctx) < 0)
return -1;
return 0;
return 1;
}
static struct maildir_copy_context *
{
struct maildir_copy_context *ctx;
return ctx;
}
{
}
return 0;
}
{
t_push();
t_pop();
}
}
{
struct maildir_transaction_context *t =
(struct maildir_transaction_context *)_t;
struct maildir_copy_context *ctx;
int ret;
// FIXME: handle dest_mail
t_push();
t_pop();
if (ret > 0)
return 0;
if (ret < 0)
return -1;
/* non-fatal hardlinking failure, try the slow way */
}
}