if (!ctx->failed)
ctx->mail_count++;
- else {
- if (unlink(path) < 0) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
- "unlink(%s) failed: %m", path);
- }
- }
+ else
+ i_unlink(path);
index_mail_cache_parse_deinit(_ctx->dest_mail,
_ctx->data.received_date, !ctx->failed);
str_truncate(ctx->path, ctx->path_dir_prefix_len);
str_printfa(ctx->path, "%u.", uid);
- if (unlink(str_c(ctx->path)) == 0) {
+ if (i_unlink_if_exists(str_c(ctx->path)) < 0) {
+ /* continue anyway */
+ } else {
if (box->v.sync_notify != NULL) {
box->v.sync_notify(box, uid,
MAILBOX_SYNC_TYPE_EXPUNGE);
}
mail_index_expunge(ctx->trans, seq1);
- } else if (errno != ENOENT) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
- "unlink(%s) failed: %m", str_c(ctx->path));
- /* continue anyway */
}
}
}
if (ctx->failed) {
/* delete the tmp file */
- if (unlink(path) < 0 && errno != ENOENT) {
- mail_storage_set_critical(storage,
- "unlink(%s) failed: %m", path);
- }
+ i_unlink_if_exists(path);
errno = output_errno;
if (ENOQUOTA(errno)) {
and hope that another process didn't just decide to
unlink() the other (uidlist lock prevents this from
happening) */
- if (unlink(path2) == 0)
+ if (i_unlink(path2) == 0)
i_warning("Unlinked a duplicate: %s", path2);
- else {
- mail_storage_set_critical(
- &ctx->mbox->storage->storage,
- "unlink(%s) failed: %m", path2);
- }
}
return 0;
}
}
}
- if (ret < 0) {
- if (unlink(temp_path) < 0) {
- mail_storage_set_critical(box->storage,
- "unlink(%s) failed: %m", temp_path);
- }
- } else if (fstat(fd, &st) < 0) {
+ if (ret < 0)
+ i_unlink(temp_path);
+ else if (fstat(fd, &st) < 0) {
mail_storage_set_critical(box->storage,
"fstat(%s) failed: %m", temp_path);
ret = -1;