dovecot-2.2: lib-storage: Replaced some unlink()s with i_unlink*...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 8 16:14:16 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/11e13b7df9f6
changeset: 19138:11e13b7df9f6
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 19:12:26 2015 +0300
description:
lib-storage: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_storage_set_critical() calls to i_error()s, but
because these unlink() failures don't actually fail the operation it doesn't
matter.
diffstat:
src/lib-storage/index/cydir/cydir-save.c | 8 ++------
src/lib-storage/index/cydir/cydir-sync.c | 8 +++-----
src/lib-storage/index/maildir/maildir-save.c | 5 +----
src/lib-storage/index/maildir/maildir-sync.c | 7 +------
src/lib-storage/index/maildir/maildir-uidlist.c | 9 +++------
5 files changed, 10 insertions(+), 27 deletions(-)
diffs (93 lines):
diff -r 27a629e444b2 -r 11e13b7df9f6 src/lib-storage/index/cydir/cydir-save.c
--- a/src/lib-storage/index/cydir/cydir-save.c Tue Sep 08 19:11:45 2015 +0300
+++ b/src/lib-storage/index/cydir/cydir-save.c Tue Sep 08 19:12:26 2015 +0300
@@ -218,12 +218,8 @@
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);
diff -r 27a629e444b2 -r 11e13b7df9f6 src/lib-storage/index/cydir/cydir-sync.c
--- a/src/lib-storage/index/cydir/cydir-sync.c Tue Sep 08 19:11:45 2015 +0300
+++ b/src/lib-storage/index/cydir/cydir-sync.c Tue Sep 08 19:12:26 2015 +0300
@@ -41,16 +41,14 @@
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 */
}
}
}
diff -r 27a629e444b2 -r 11e13b7df9f6 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c Tue Sep 08 19:11:45 2015 +0300
+++ b/src/lib-storage/index/maildir/maildir-save.c Tue Sep 08 19:12:26 2015 +0300
@@ -624,10 +624,7 @@
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)) {
diff -r 27a629e444b2 -r 11e13b7df9f6 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c Tue Sep 08 19:11:45 2015 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c Tue Sep 08 19:12:26 2015 +0300
@@ -325,13 +325,8 @@
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;
}
diff -r 27a629e444b2 -r 11e13b7df9f6 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Tue Sep 08 19:11:45 2015 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c Tue Sep 08 19:12:26 2015 +0300
@@ -1453,12 +1453,9 @@
}
}
- 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;
More information about the dovecot-cvs
mailing list