Teach magic-folder join to use configutil.

Author: David Stainton <david@leastauthority.com>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-12-21 21:59:57 +00:00 committed by Brian Warner
parent cc721505e7
commit 278762200d

View File

@ -13,6 +13,7 @@ import tahoe_mv
from allmydata.util.encodingutil import argv_to_abspath, argv_to_unicode, to_str, \ from allmydata.util.encodingutil import argv_to_abspath, argv_to_unicode, to_str, \
quote_local_unicode_path quote_local_unicode_path
from allmydata.util import fileutil from allmydata.util import fileutil
from allmydata.util import configutil
from allmydata import uri from allmydata import uri
INVITE_SEPARATOR = "+" INVITE_SEPARATOR = "+"
@ -163,10 +164,10 @@ def join(options):
fileutil.write(dmd_cap_file, dmd_write_cap) fileutil.write(dmd_cap_file, dmd_write_cap)
fileutil.write(collective_readcap_file, magic_readonly_cap) fileutil.write(collective_readcap_file, magic_readonly_cap)
# FIXME: modify any existing [magic_folder] fields, rather than appending. config = configutil.get_config(os.path.join(options["node-directory"], u"tahoe.cfg"))
fileutil.write(os.path.join(options["node-directory"], u"tahoe.cfg"), configutil.set_config(config, "magic_folder", "enabled", "True")
"[magic_folder]\nenabled = True\nlocal.directory = %s\n" configutil.set_config(config, "magic_folder", "local.directory", options.local_dir.encode('utf-8'))
% (options.local_dir.encode('utf-8'),), mode="ab") configutil.write_config(os.path.join(options["node-directory"], u"tahoe.cfg"), config)
return 0 return 0
class LeaveOptions(BasedirOptions): class LeaveOptions(BasedirOptions):