From: David Stainton <dstainton415@gmail.com>
Date: Tue, 10 Nov 2015 15:24:44 +0000 (+0100)
Subject: teach leave to: remove magic_folder section of config
X-Git-Url: https://git.rkrishnan.org/simplejson/components/COPYING.TGPPL.html?a=commitdiff_plain;h=3e7749d4b4871edb7e7bde3a08af9a7a0be322cc;p=tahoe-lafs%2Ftahoe-lafs.git

teach leave to: remove magic_folder section of config
---

diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py
index 098b2fcc..1b7ff39a 100644
--- a/src/allmydata/scripts/magic_folder_cli.py
+++ b/src/allmydata/scripts/magic_folder_cli.py
@@ -172,9 +172,19 @@ class LeaveOptions(BasedirOptions):
         BasedirOptions.parseArgs(self)
 
 def leave(options):
+    from ConfigParser import SafeConfigParser
+
     dmd_cap_file = os.path.join(options["node-directory"], u"private", u"magic_folder_dircap")
     collective_readcap_file = os.path.join(options["node-directory"], u"private", u"collective_dircap")
     magic_folder_db_file = os.path.join(options["node-directory"], u"private", u"magicfolderdb.sqlite")
+
+    parser = SafeConfigParser()
+    parser.read(os.path.join(options["node-directory"], u"tahoe.cfg"))
+    parser.remove_section("magic_folder")
+    f = open(os.path.join(options["node-directory"], u"tahoe.cfg"), "w")
+    parser.write(f)
+    f.close()
+
     for f in [dmd_cap_file, collective_readcap_file, magic_folder_db_file]:
         try:
             os.remove(f)