From 29027e9e3d0d1cbaf71f4788089fd12ad6b6a36c Mon Sep 17 00:00:00 2001 From: David Stainton Date: Thu, 5 Nov 2015 17:24:52 +0100 Subject: [PATCH] Add simple magic-folder leave command --- src/allmydata/scripts/magic_folder_cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py index 7b63a70d..098b2fcc 100644 --- a/src/allmydata/scripts/magic_folder_cli.py +++ b/src/allmydata/scripts/magic_folder_cli.py @@ -166,11 +166,28 @@ def join(options): % (options.local_dir.encode('utf-8'),), mode="ab") return 0 +class LeaveOptions(BasedirOptions): + synopsis = "" + def parseArgs(self): + BasedirOptions.parseArgs(self) + +def leave(options): + 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") + for f in [dmd_cap_file, collective_readcap_file, magic_folder_db_file]: + try: + os.remove(f) + except OSError,e: + pass + return 0 + class MagicFolderCommand(BaseOptions): subCommands = [ ["create", None, CreateOptions, "Create a Magic Folder."], ["invite", None, InviteOptions, "Invite someone to a Magic Folder."], ["join", None, JoinOptions, "Join a Magic Folder."], + ["leave", None, LeaveOptions, "Leave a Magic Folder."], ] def postOptions(self): if not hasattr(self, 'subOptions'): @@ -189,6 +206,7 @@ subDispatch = { "create": create, "invite": invite, "join": join, + "leave": leave, } def do_magic_folder(options): -- 2.45.2