dovecot-2.2: lib-index: Replaced some unlink()s with i_unlink*()...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 8 16:14:15 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/27a629e444b2
changeset: 19137:27a629e444b2
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 19:11:45 2015 +0300
description:
lib-index: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_index_set_error() calls to i_error()s, but because
these unlink() failures don't actually fail the operation it doesn't matter.
In fact it may be even better that it doesn't overwrite the existing
index->error if it exists.
diffstat:
src/lib-index/mail-index-write.c | 8 ++------
src/lib-index/mail-transaction-log-file.c | 11 +++--------
src/lib-index/mail-transaction-log.c | 8 ++------
3 files changed, 7 insertions(+), 20 deletions(-)
diffs (64 lines):
diff -r fefaa6d09a81 -r 27a629e444b2 src/lib-index/mail-index-write.c
--- a/src/lib-index/mail-index-write.c Tue Sep 08 19:07:02 2015 +0300
+++ b/src/lib-index/mail-index-write.c Tue Sep 08 19:11:45 2015 +0300
@@ -110,12 +110,8 @@
ret = -1;
}
- if (ret < 0) {
- if (unlink(path) < 0) {
- mail_index_set_error(index, "unlink(%s) failed: %m",
- path);
- }
- }
+ if (ret < 0)
+ i_unlink(path);
return ret;
}
diff -r fefaa6d09a81 -r 27a629e444b2 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Tue Sep 08 19:07:02 2015 +0300
+++ b/src/lib-index/mail-transaction-log-file.c Tue Sep 08 19:11:45 2015 +0300
@@ -794,9 +794,7 @@
file_dotlock_replace(). during that time the log file
doesn't exist, which could cause problems. */
path2 = t_strconcat(file->filepath, ".2", NULL);
- if (unlink(path2) < 0 && errno != ENOENT) {
- mail_index_set_error(index, "unlink(%s) failed: %m",
- path2);
+ if (i_unlink_if_exists(path2) < 0) {
/* try to link() anyway */
}
if (nfs_safe_link(file->filepath, path2, FALSE) < 0 &&
@@ -916,11 +914,8 @@
/* corrupted */
if (index->readonly) {
/* don't delete */
- } else if (unlink(file->filepath) < 0 &&
- errno != ENOENT) {
- mail_index_set_error(index,
- "unlink(%s) failed: %m",
- file->filepath);
+ } else {
+ i_unlink_if_exists(file->filepath);
}
return 0;
}
diff -r fefaa6d09a81 -r 27a629e444b2 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c Tue Sep 08 19:07:02 2015 +0300
+++ b/src/lib-index/mail-transaction-log.c Tue Sep 08 19:11:45 2015 +0300
@@ -52,12 +52,8 @@
}
if (st.st_mtime + MAIL_TRANSACTION_LOG2_STALE_SECS <= ioloop_time &&
- !log->index->readonly) {
- if (unlink(log->filepath2) < 0 && errno != ENOENT) {
- mail_index_set_error(log->index,
- "unlink(%s) failed: %m", log->filepath2);
- }
- }
+ !log->index->readonly)
+ i_unlink_if_exists(log->filepath2);
}
int mail_transaction_log_open(struct mail_transaction_log *log)
More information about the dovecot-cvs
mailing list