maildir-save.c revision 9aba3468134d4f5130c1d36c53b8664be4ef30d7
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen/* Copyright (C) 2002-2004 Timo Sirainen */
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen /* unsigned int keywords[]; */
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen struct maildir_uidlist_sync_ctx *uidlist_sync_ctx;
09caccbfa7a47fbcd428b0618dfdf46d1679390aTimo Sirainen struct maildir_filename *files, **files_tail, *file_last;
e6837a4f1118565d2ac460dce140705d56f779b3Timo Sirainenstatic int maildir_file_move(struct maildir_save_context *ctx,
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen struct mail_storage *storage = STORAGE(ctx->mbox->storage);
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen /* if we have flags, we'll move it to cur/ directly, because files in
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen new/ directory can't have flags. alternative would be to write it
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen in new/ and set the flags dirty in index file, but in that case
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen external MUAs would see wrong flags. */
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen tmp_path = t_strconcat(ctx->tmpdir, "/", tmpname, NULL);
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen t_strconcat(ctx->newdir, "/", destname, NULL) :
5140f38cb347593aa60a44ab4b0fe60a0b17f808Timo Sirainen t_strconcat(ctx->curdir, "/", destname, NULL);
c1252a5812eb11fcb81508b9ed37597a5bc84100Timo Sirainen /* maildir spec says we should use link() + unlink() here. however
74ae32512357bdd4872bf160dc697ff7b54b54c5Timo Sirainen since our filename is guaranteed to be unique, rename() works just
74ae32512357bdd4872bf160dc697ff7b54b54c5Timo Sirainen as well, except faster. even if the filename wasn't unique, the
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen problem could still happen if the file was already moved from
ret = 0;
t_pop();
return ret;
struct maildir_save_context *
return ctx;
i_unreached();
const char **fname_r)
return TRUE;
return FALSE;
return FALSE;
const char *fname;
struct maildir_transaction_context *t =
while (seq > 0) {
seq--;
struct maildir_transaction_context *t =
t_push();
&path);
t_pop();
fname++;
MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
t_pop();
const char *path;
int output_errno;
t_push();
} else if (errno != 0) {
t_pop();
t_pop();
t_push();
t_pop();
const char *dest;
int ret;
ret = 0;
t_push();
if (ret == 0) {
t_pop();
!sync_commit) < 0)
if (ret < 0) {
return ret;
t_push();
if (hardlinks)
t_pop();