comparison src/lib-storage/index/cydir/cydir-save.c @ 6940:414c9d631a81 HEAD

Replaced t_push/t_pop calls with T_FRAME*() macros.
author Timo Sirainen <tss@iki.fi>
date Wed, 05 Dec 2007 17:47:44 +0200
parents 9ca7f055b646
children 7ed926ed7aa4
comparison
equal deleted inserted replaced
6939:c7b42fea5fcc 6940:414c9d631a81
68 (struct cydir_transaction_context *)_t; 68 (struct cydir_transaction_context *)_t;
69 struct cydir_mailbox *mbox = (struct cydir_mailbox *)t->ictx.ibox; 69 struct cydir_mailbox *mbox = (struct cydir_mailbox *)t->ictx.ibox;
70 struct cydir_save_context *ctx = t->save_ctx; 70 struct cydir_save_context *ctx = t->save_ctx;
71 enum mail_flags save_flags; 71 enum mail_flags save_flags;
72 struct istream *crlf_input; 72 struct istream *crlf_input;
73 const char *path;
74 73
75 i_assert((t->ictx.flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0); 74 i_assert((t->ictx.flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
76 75
77 if (ctx == NULL) { 76 if (ctx == NULL) {
78 ctx = t->save_ctx = i_new(struct cydir_save_context, 1); 77 ctx = t->save_ctx = i_new(struct cydir_save_context, 1);
80 ctx->mbox = mbox; 79 ctx->mbox = mbox;
81 ctx->trans = t->ictx.trans; 80 ctx->trans = t->ictx.trans;
82 ctx->tmp_basename = cydir_generate_tmp_filename(); 81 ctx->tmp_basename = cydir_generate_tmp_filename();
83 } 82 }
84 83
85 t_push(); 84 T_FRAME(
86 path = cydir_get_save_path(ctx, ctx->mail_count); 85 const char *path;
87 ctx->fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0660); 86
88 if (ctx->fd != -1) { 87 path = cydir_get_save_path(ctx, ctx->mail_count);
89 ctx->output = o_stream_create_fd_file(ctx->fd, 0, FALSE); 88 ctx->fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0660);
90 o_stream_cork(ctx->output); 89 if (ctx->fd != -1) {
91 } else { 90 ctx->output =
92 mail_storage_set_critical(_t->box->storage, 91 o_stream_create_fd_file(ctx->fd, 0, FALSE);
93 "open(%s) failed: %m", path); 92 o_stream_cork(ctx->output);
94 ctx->failed = TRUE; 93 } else {
95 t_pop(); 94 mail_storage_set_critical(_t->box->storage,
95 "open(%s) failed: %m", path);
96 ctx->failed = TRUE;
97 }
98 );
99 if (ctx->failed)
96 return -1; 100 return -1;
97 }
98 t_pop();
99 101
100 /* add to index */ 102 /* add to index */
101 save_flags = flags & ~MAIL_RECENT; 103 save_flags = flags & ~MAIL_RECENT;
102 mail_index_append(ctx->trans, 0, &ctx->seq); 104 mail_index_append(ctx->trans, 0, &ctx->seq);
103 mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE, 105 mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE,