]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Replaced some unlink()s with i_unlink*()s where we could.
authorTimo Sirainen <tss@iki.fi>
Tue, 8 Sep 2015 16:11:45 +0000 (19:11 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 8 Sep 2015 16:11:45 +0000 (19:11 +0300)
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.

src/lib-index/mail-index-write.c
src/lib-index/mail-transaction-log-file.c
src/lib-index/mail-transaction-log.c

index 8e8ebfa672952ece70a696be6f99525e8b0afd17..e8eb7c06ede75725afa0d26fa059595011f09b86 100644 (file)
@@ -110,12 +110,8 @@ static int mail_index_recreate(struct mail_index *index)
                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;
 }
 
index ce1745010829e2e6e1666bcc8b2b98f3841387ed..eea8e59a62856d92454571d40c711dc1c5a12386 100644 (file)
@@ -794,9 +794,7 @@ mail_transaction_log_file_create2(struct mail_transaction_log_file *file,
                   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 @@ int mail_transaction_log_file_open(struct mail_transaction_log_file *file)
                        /* 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;
                }
index e5a6d26ce4b81212c121b83f6aa88411a10cd2f8..d7da173533e21827bc78586b756bdc0ffce08380 100644 (file)
@@ -52,12 +52,8 @@ static void mail_transaction_log_2_unlink_old(struct mail_transaction_log *log)
        }
 
        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)