[Commits] [SCM] claws branch, master, updated. 3.14.1-200-g91af1a4

mones at claws-mail.org mones at claws-mail.org
Fri Feb 24 23:55:38 CET 2017


The branch, master has been updated
       via  91af1a4bee0153e9f2abd047e025d94f3f84fbac (commit)
      from  cc3882f3602f1b44407248a19ab2c40175b98f91 (commit)

Summary of changes:
 src/account.c       |   27 ++++++++++++++++++++++++++-
 src/prefs_account.c |   41 +++++++++++++++++++++++++++++++++++++++++
 src/prefs_account.h |    2 ++
 3 files changed, 69 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit 91af1a4bee0153e9f2abd047e025d94f3f84fbac
Author: Ricardo Mones <ricardo at mones.org>
Date:   Tue Feb 21 19:05:19 2017 +0100

    Fix bug #3741: Deleting an account doesn't delete imapcache
    
    Based on initial patch by Paul and in exchange of a reviewed
    patch for 3582 ;-)

diff --git a/src/account.c b/src/account.c
index 5ff5d64..9625056 100644
--- a/src/account.c
+++ b/src/account.c
@@ -1059,6 +1059,27 @@ static void account_clone(GtkWidget *widget, gpointer data)
 #undef ACP_FDUP
 #undef ACP_FASSIGN
 
+static void account_empty_cache(PrefsAccount *ac_prefs)
+{
+	gchar *cache_dir;
+
+	cache_dir = prefs_account_cache_dir(ac_prefs, FALSE);
+	if (cache_dir == NULL)
+		return; /* no cache dir, nothing to do */
+
+	if (is_dir_exist(cache_dir) && remove_dir_recursive(cache_dir) < 0) {
+		g_warning("can't remove directory '%s'", cache_dir);
+	} else {
+		gchar *server_dir =  prefs_account_cache_dir(ac_prefs, TRUE);
+		if (g_rmdir(server_dir) == 0)
+			debug_print("Removed empty cache server directory\n");
+		else
+			debug_print("Cache server directory not empty: not removed\n");
+		g_free(server_dir);
+	}
+	g_free(cache_dir);
+}
+
 static void account_delete(GtkWidget *widget, gpointer data)
 {
 	PrefsAccount *ac_prefs;
@@ -1066,7 +1087,7 @@ static void account_delete(GtkWidget *widget, gpointer data)
 	GList *list;
 	Folder *folder;
 	GSList *cur;
- 
+
  	ac_prefs = account_list_view_get_selected_account(edit_account.list_view);
  	if (ac_prefs == NULL)
  		return;
@@ -1123,6 +1144,10 @@ static void account_delete(GtkWidget *widget, gpointer data)
 			cur = g_slist_next(cur);
 		}
 	}
+
+	debug_print("Removing cache directory of this account...\n");
+	account_empty_cache(ac_prefs);
+
 	folder_write_list();
 }
 
diff --git a/src/prefs_account.c b/src/prefs_account.c
index 9fc9616..185e24d 100644
--- a/src/prefs_account.c
+++ b/src/prefs_account.c
@@ -4962,3 +4962,44 @@ void prefs_account_unregister_page(PrefsPage *page)
 {
 	prefs_pages = g_slist_remove(prefs_pages, page);
 }
+
+gchar *prefs_account_cache_dir(PrefsAccount *ac_prefs, gboolean for_server)
+{
+	gchar *dir = NULL;
+#ifdef G_OS_WIN32
+	gchar *sanitized_server;
+#endif
+
+	if (ac_prefs->protocol == A_IMAP4) {
+#ifdef G_OS_WIN32
+		sanitized_server = g_strdup(ac_prefs->recv_server);
+		g_strdelimit(sanitized_server, ":", ',');
+#endif
+		if (for_server) {
+			dir = g_strconcat(get_imap_cache_dir(),
+					  G_DIR_SEPARATOR_S,
+#ifdef G_OS_WIN32
+					  sanitized_server,
+#else
+					  ac_prefs->recv_server,
+#endif
+					  NULL);
+		} else {
+			dir = g_strconcat(get_imap_cache_dir(),
+					  G_DIR_SEPARATOR_S,
+#ifdef G_OS_WIN32
+					  sanitized_server,
+#else
+					  ac_prefs->recv_server,
+#endif
+					  G_DIR_SEPARATOR_S,
+					  ac_prefs->userid,
+					  NULL);
+		}
+#ifdef G_OS_WIN32
+		g_free(sanitized_server);
+#endif
+	}
+
+	return dir;
+}
diff --git a/src/prefs_account.h b/src/prefs_account.h
index f7feb13..83f6efa 100644
--- a/src/prefs_account.h
+++ b/src/prefs_account.h
@@ -228,4 +228,6 @@ gchar *prefs_account_generate_msgid(PrefsAccount *account);
 void prefs_account_register_page	(PrefsPage 	*page);
 void prefs_account_unregister_page	(PrefsPage 	*page);
 
+gchar *prefs_account_cache_dir		(PrefsAccount	*ac_prefs, gboolean for_server);
+
 #endif /* PREFS_ACCOUNT_H */

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list