[PATCH 22/65] remove infile when leaving a channel

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Thu, 17 Apr 2014 17:05:41 +0200

don't write own "nickname has left" to the channel to prevent recreating the channel

Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
---
 ii.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/ii.c b/ii.c
index b0b83db..ca24a3c 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -307,10 +307,11 @@ proc_channels_input(int fd, Channel *c, char *buf) {
 				         "PART %s :ii - 500 SLOC are too much\r\n", c->name);
 			write(fd, msg, strnlen(msg, sizeof(msg)));
 			close(c->fd);
-			/* TODO: dont create directory before deleting in file
-			 * just try to delete it immediately */
-			create_filepath(infile, sizeof(infile), c->name, "in");
-			unlink(infile);
+			/* remove "in" file on leaving the channel */
+			if(snprintf(infile, sizeof(infile), "%s/%s/in",
+				path, c->name) > 0) {
+				unlink(infile);
+			}
 			rm_channel(c);
 			return;
 			break;
_AT_@ -388,6 +389,9 @@ proc_server_cmd(int fd, char *buf) {
 	} else if(!strncmp("PART", argv[TOK_CMD], 5)) {
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has left %s",
 				argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_CHAN]);
+		/* if user itself leaves, don't write to out (don't reopen channel). */
+		if(!strcmp(argv[TOK_NICKSRV], nick))
+			return;
 	} else if(!strncmp("MODE", argv[TOK_CMD], 5))
 		snprintf(msg, sizeof(msg), "-!- %s changed mode/%s -> %s %s",
 				argv[TOK_NICKSRV],
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0023-write-global-messages-to-the-correct-fd-bug-from-cle.patch"
Content-Disposition: attachment;
 filename="0023-write-global-messages-to-the-correct-fd-bug-from-cle.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST