[Commits] [SCM] claws branch, master, updated. 3.13.0-47-ga5304d0

ticho at claws-mail.org ticho at claws-mail.org
Wed Nov 11 16:47:55 CET 2015


The branch, master has been updated
       via  a5304d00b20f8b6845b54f5833cdd2d3c067dc42 (commit)
       via  37c86c13b4735719aa14390b70c0a104e3184271 (commit)
      from  f2952c9fb89697290384a97cd27ab6c538430b54 (commit)

Summary of changes:
 src/addrharvest.c  |   37 +++++++++++++++++++------------------
 src/common/utils.c |   31 ++++++++-----------------------
 2 files changed, 27 insertions(+), 41 deletions(-)


- Log -----------------------------------------------------------------
commit a5304d00b20f8b6845b54f5833cdd2d3c067dc42
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Wed Nov 11 16:30:11 2015 +0100

    Do not use chdir() in addrharvest.c.

diff --git a/src/addrharvest.c b/src/addrharvest.c
index 97eff8b..75f3b80 100644
--- a/src/addrharvest.c
+++ b/src/addrharvest.c
@@ -765,9 +765,11 @@ static void addrharvest_harvest_dir(
 {
 	GDir *dp;
 	const gchar *d;
+	gchar *fullname;
 	GError *error = NULL;
 	gint num;
-	int r;
+
+	debug_print("Harvesting addresses from dir '%s'\n", dir);
 
 	if( ( dp = g_dir_open( dir, 0, &error ) ) == NULL ) {
 		debug_print("opening '%s' failed: %d (%s)\n", dir,
@@ -777,24 +779,27 @@ static void addrharvest_harvest_dir(
 	}
 
 	/* Process directory */
-	r = g_chdir( dir );
-	while( r == 0 && ( d = g_dir_read_name( dp ) ) != NULL ) {
-		if( g_file_test(d, G_FILE_TEST_IS_DIR) ) {
+	while( (d = g_dir_read_name( dp )) != NULL ) {
+		fullname = g_strconcat(dir, G_DIR_SEPARATOR_S, d, NULL);
+		if( g_file_test(fullname, G_FILE_TEST_IS_DIR) ) {
 			if( harvester->folderRecurse ) {
-				if( strstr( DIR_IGNORE, d ) != NULL )
+				if( strstr( DIR_IGNORE, d ) != NULL ) {
+					g_free(fullname);
 					continue;
+				}
+
 				addrharvest_harvest_dir(
-					harvester, cache, listHdr, (gchar *)d );
+					harvester, cache, listHdr, (gchar *)fullname );
 			}
 		}
-		if( g_file_test(d, G_FILE_TEST_IS_REGULAR) ) {
+		if( g_file_test(fullname, G_FILE_TEST_IS_REGULAR) ) {
 			if( ( num = to_number( d ) ) >= 0 ) {
 				addrharvest_readfile(
-					harvester, d, cache, listHdr );
+					harvester, fullname, cache, listHdr );
 			}
 		}
+		g_free(fullname);
 	}
-	r = g_chdir( ".." );
 	g_dir_close( dp );
 }
 
@@ -810,8 +815,7 @@ static void addrharvest_harvest_list(
 {
 	gint num;
 	GList *node;
-	gchar msgNum[ MSGNUM_BUFFSIZE ];
-	int r;
+	gchar *fullname;
 
 	if (!g_file_test(harvester->path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 		debug_print("'%s' doesn't exist or is not a dir\n", harvester->path);
@@ -819,16 +823,13 @@ static void addrharvest_harvest_list(
 	}
 
 	/* Process message list */
-	r = g_chdir( harvester->path );
-	if (r != 0) {
-		g_message("cannot g_chdir to '%s'\n", harvester->path);
-		return;
-	}
 	node = msgList;
 	while( node ) {
 		num = GPOINTER_TO_UINT( node->data );
-		sprintf( msgNum, "%d", num );
-		addrharvest_readfile( harvester, msgNum, cache, listHdr );
+		fullname = g_strdup_printf("%s%c%d",
+				harvester->path, G_DIR_SEPARATOR, num);
+		addrharvest_readfile( harvester, fullname, cache, listHdr );
+		g_free(fullname);
 		node = g_list_next( node );
 	}
 }

commit 37c86c13b4735719aa14390b70c0a104e3184271
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Nov 6 20:05:00 2015 +0100

    Do not use chdir() in remove_all_files().

diff --git a/src/common/utils.c b/src/common/utils.c
index b3038ee..f16c00b 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -2195,38 +2195,23 @@ gint make_dir_hier(const gchar *dir)
 gint remove_all_files(const gchar *dir)
 {
 	GDir *dp;
-	const gchar *dir_name;
-	gchar *prev_dir;
-
-	prev_dir = g_get_current_dir();
-
-	if (g_chdir(dir) < 0) {
-		FILE_OP_ERROR(dir, "chdir");
-		g_free(prev_dir);
-		return -1;
-	}
+	const gchar *file_name;
+	gchar *tmp;
 
-	if ((dp = g_dir_open(".", 0, NULL)) == NULL) {
+	if ((dp = g_dir_open(dir, 0, NULL)) == NULL) {
 		g_warning("failed to open directory: %s", dir);
-		g_free(prev_dir);
 		return -1;
 	}
 
-	while ((dir_name = g_dir_read_name(dp)) != NULL) {
-		if (claws_unlink(dir_name) < 0)
-			FILE_OP_ERROR(dir_name, "unlink");
+	while ((file_name = g_dir_read_name(dp)) != NULL) {
+		tmp = g_strconcat(dir, G_DIR_SEPARATOR_S, file_name, NULL);
+		if (claws_unlink(tmp) < 0)
+			FILE_OP_ERROR(tmp, "unlink");
+		g_free(tmp);
 	}
 
 	g_dir_close(dp);
 
-	if (g_chdir(prev_dir) < 0) {
-		FILE_OP_ERROR(prev_dir, "chdir");
-		g_free(prev_dir);
-		return -1;
-	}
-
-	g_free(prev_dir);
-
 	return 0;
 }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list