dovecot-2.2: plugins/fts: expung-log - add the concept of not un...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jan 20 23:55:04 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/2e756ad0ffcf
changeset: 18191:2e756ad0ffcf
user:      Phil Carmody <phil at dovecot.fi>
date:      Wed Jan 21 01:46:13 2015 +0200
description:
plugins/fts: expung-log - add the concept of not unlinking at the end
No behavioural differences, the default is to unlink.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/plugins/fts/fts-expunge-log.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (39 lines):

diff -r 230f3579c9b7 -r 2e756ad0ffcf src/plugins/fts/fts-expunge-log.c
--- a/src/plugins/fts/fts-expunge-log.c	Wed Jan 21 01:44:31 2015 +0200
+++ b/src/plugins/fts/fts-expunge-log.c	Wed Jan 21 01:46:13 2015 +0200
@@ -61,6 +61,7 @@
 
 	bool failed;
 	bool corrupted;
+	bool unlink;
 };
 
 struct fts_expunge_log *fts_expunge_log_init(const char *path)
@@ -348,6 +349,7 @@
 		ctx->failed = TRUE;
 	else if (log->fd != -1)
 		ctx->input = i_stream_create_fd(log->fd, (size_t)-1, FALSE);
+	ctx->unlink = TRUE;
 	return ctx;
 }
 
@@ -395,7 +397,8 @@
 	(void)i_stream_read_data(ctx->input, &data, &size, IO_BLOCK_SIZE);
 	if (size == 0 && ctx->input->stream_errno == 0) {
 		/* expected EOF - mark the file as read by unlinking it */
-		if (unlink(ctx->log->path) < 0 && errno != ENOENT)
+		if (ctx->unlink &&
+		    unlink(ctx->log->path) < 0 && errno != ENOENT)
 			i_error("unlink(%s) failed: %m", ctx->log->path);
 
 		/* try reading again, in case something new was written */
@@ -462,7 +465,8 @@
 	*_ctx = NULL;
 
 	if (ctx->corrupted) {
-		if (unlink(ctx->log->path) < 0 && errno != ENOENT)
+		if (ctx->unlink &&
+		    unlink(ctx->log->path) < 0 && errno != ENOENT)
 			i_error("unlink(%s) failed: %m", ctx->log->path);
 	}
 


More information about the dovecot-cvs mailing list