[Xfce4-commits] <postler:master> Remove account folder on disk when deleting account

Christian Dywan noreply at xfce.org
Thu Feb 24 03:48:02 CET 2011


Updating branch refs/heads/master
         to c195a87ee320bb3c75380d02e749669817e3241f (commit)
       from 1be19a6e8a1ac2d6d77801f2a8911aca9f4a6602 (commit)

commit c195a87ee320bb3c75380d02e749669817e3241f
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Feb 24 03:38:25 2011 +0100

    Remove account folder on disk when deleting account

 postler/postler-accounts.vala |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index e0bb5fa..62d5069 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -299,9 +299,31 @@ public class Postler.Accounts : GLib.Object {
         }
     }
 
+    bool remove_path (string path) throws GLib.FileError {
+        Dir dir;
+        try {
+            dir = Dir.open (path, 0);
+        }
+        catch (Error error) {
+            return FileUtils.remove (path) == 0;
+        }
+        string? name;
+        while ((name = dir.read_name ()) != null) {
+            string subpath = Path.build_filename (path, name);
+            if (!remove_path (subpath))
+                return false;
+        }
+        return FileUtils.remove (path) == 0;
+    }
+
     void delete_account (AccountInfo info)
         requires (info.name != null) {
         try {
+            if (info.type == AccountType.IMAP) {
+                if (!remove_path (info.path))
+                    throw new GLib.FileError.FAILED (
+                        _("Failed to remove \"%s\"").printf (info.path));
+            }
             keyfile.remove_group (info.name);
             write_keyfile ();
         }



More information about the Xfce4-commits mailing list