From d5075d3dfd69bf50edfb4dc4e71f8d5242ba5ebe Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Thu, 5 Nov 2015 16:56:31 +0100
Subject: [PATCH] Prevent magic-folder join if already joined.

---
 src/allmydata/scripts/magic_folder_cli.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py
index e25f7b54..245a9b6a 100644
--- a/src/allmydata/scripts/magic_folder_cli.py
+++ b/src/allmydata/scripts/magic_folder_cli.py
@@ -153,6 +153,9 @@ def join(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")
 
+    if os.path.exists(dmd_cap_file) or os.path.exists(collective_readcap_file):
+        raise usage.UsageError("Cannot join. Already joined.")
+
     fileutil.write(dmd_cap_file, dmd_write_cap)
     fileutil.write(collective_readcap_file, magic_readonly_cap)
 
-- 
2.45.2