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

src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/cydir/cydir-sync.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/maildir/maildir-uidlist.c

index ca7316e805c6f5b15c7caf5dd1720dbea7e9e308..063b59c0da6227b13b65cd61d5c94ca488faa3e4 100644 (file)
@@ -218,12 +218,8 @@ int cydir_save_finish(struct mail_save_context *_ctx)
 
        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);
index 9b005b86022e16a52daf86ca50d8fc138a6538ba..3e6122858b37034cc92bbe752f53d4472729dc18 100644 (file)
@@ -41,16 +41,14 @@ cydir_sync_expunge(struct cydir_sync_context *ctx, uint32_t seq1, uint32_t seq2)
 
                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 */
                }
        }
 }
index ea3805cdca769e5e4554e16c6a0c4ae661fad897..6271af4e6a2be6b6e5797d06fd5d4f9b14b56083 100644 (file)
@@ -624,10 +624,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
 
        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)) {
index 8bf16aaa64ed007db6de273d9a89b37228573fde..5dd6a933fab97c1aacb68ab5ca3de05598dafb8c 100644 (file)
@@ -325,13 +325,8 @@ static int maildir_fix_duplicate(struct maildir_sync_context *ctx,
                           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;
        }
index 71614985e19afce9798532087d013bbc08f87b25..19034e27465a338ed8d9e8644b546f017332ed02 100644 (file)
@@ -1453,12 +1453,9 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist)
                }
        }
 
-       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;