[dovecot-cvs] dovecot/src/lib-storage/index/cydir cydir-save.c, 1.5, 1.6 cydir-storage.c, 1.13, 1.14

tss at dovecot.org tss at dovecot.org
Sun May 13 20:10:53 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/cydir
In directory talvi:/tmp/cvs-serv20721/lib-storage/index/cydir

Modified Files:
	cydir-save.c cydir-storage.c 
Log Message:
Error handling rewrite.



Index: cydir-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/cydir/cydir-save.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cydir-save.c	17 Apr 2007 17:17:59 -0000	1.5
+++ cydir-save.c	13 May 2007 17:10:50 -0000	1.6
@@ -125,16 +125,14 @@
 int cydir_save_continue(struct mail_save_context *_ctx)
 {
 	struct cydir_save_context *ctx = (struct cydir_save_context *)_ctx;
+	struct mail_storage *storage = &ctx->mbox->storage->storage;
 
 	if (ctx->failed)
 		return -1;
 
 	if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
-		if (ENOSPACE(ctx->output->stream_errno)) {
-			mail_storage_set_error(&ctx->mbox->storage->storage,
-					       "Not enough disk space");
-		} else {
-			mail_storage_set_critical(&ctx->mbox->storage->storage,
+		if (!mail_storage_set_error_from_errno(storage)) {
+			mail_storage_set_critical(storage,
 				"o_stream_send_istream(%s) failed: %m",
 				cydir_get_save_path(ctx, ctx->mail_count));
 		}

Index: cydir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/cydir/cydir-storage.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- cydir-storage.c	17 Apr 2007 12:41:27 -0000	1.13
+++ cydir-storage.c	13 May 2007 17:10:50 -0000	1.14
@@ -141,16 +141,11 @@
 
 static int create_cydir(struct mail_storage *storage, const char *path)
 {
-	const char *error;
-
 	if (mkdir_parents(path, CREATE_MODE) < 0 && errno != EEXIST) {
-		if (mail_storage_errno2str(&error)) {
-			mail_storage_set_error(storage, "%s", error);
-			return -1;
+		if (!mail_storage_set_error_from_errno(storage)) {
+			mail_storage_set_critical(storage,
+				"mkdir(%s) failed: %m", path);
 		}
-
-		mail_storage_set_critical(storage, "mkdir(%s) failed: %m",
-					  path);
 		return -1;
 	}
 	return 0;
@@ -235,8 +230,8 @@
 	if (stat(path, &st) == 0) {
 		return cydir_open(storage, name, flags);
 	} else if (errno == ENOENT) {
-		mail_storage_set_error(_storage,
-			MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name);
+		mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND,
+			T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 		return NULL;
 	} else {
 		mail_storage_set_critical(_storage, "stat(%s) failed: %m",
@@ -255,7 +250,8 @@
 	path = mailbox_list_get_path(_storage->list, name,
 				     MAILBOX_LIST_PATH_TYPE_MAILBOX);
 	if (stat(path, &st) == 0) {
-		mail_storage_set_error(_storage, "Mailbox already exists");
+		mail_storage_set_error(_storage, MAIL_ERROR_NOTPOSSIBLE,
+				       "Mailbox already exists");
 		return -1;
 	}
 
@@ -274,10 +270,7 @@
 
 	dir = opendir(path);
 	if (dir == NULL) {
-		if (errno == ENOENT) {
-			mailbox_list_set_error(list, t_strdup_printf(
-				MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name));
-		} else {
+		if (!mailbox_list_set_error_from_errno(list)) {
 			mailbox_list_set_critical(list,
 				"opendir(%s) failed: %m", path);
 		}
@@ -327,8 +320,9 @@
 	}
 
 	if (!unlinked_something) {
-		mailbox_list_set_error(list, t_strdup_printf(
-			"Directory %s isn't empty, can't delete it.", name));
+		mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE,
+			t_strdup_printf("Directory %s isn't empty, "
+					"can't delete it.", name));
 		return -1;
 	}
 	return 0;
@@ -354,8 +348,8 @@
 	/* check if the mailbox actually exists */
 	src = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX);
 	if (stat(src, &st) != 0 && errno == ENOENT) {
-		mailbox_list_set_error(list, t_strdup_printf(
-			MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name));
+		mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
+			T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 		return -1;
 	}
 



More information about the dovecot-cvs mailing list