Prepare to move drop_upload.py to magic_folder.py.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood
2015-09-16 14:59:49 +01:00
committed by Brian Warner
parent 76a178969d
commit 3170cab0fc
4 changed files with 60 additions and 56 deletions

View File

@ -144,7 +144,7 @@ class Client(node.Node, pollmixin.PollMixin):
self.init_helper()
self.init_ftp_server()
self.init_sftp_server()
self.init_drop_uploader()
self.init_magic_folder()
# If the node sees an exit_trigger file, it will poll every second to see
# whether the file still exists, and what its mtime is. If the file does not
@ -472,28 +472,31 @@ class Client(node.Node, pollmixin.PollMixin):
sftp_portstr, pubkey_file, privkey_file)
s.setServiceParent(self)
def init_drop_uploader(self):
def init_magic_folder(self):
#print "init_magic_folder"
if self.get_config("drop_upload", "enabled", False, boolean=True):
if self.get_config("drop_upload", "upload.dircap", None):
raise OldConfigOptionError("The [drop_upload]upload.dircap option is no longer supported; please "
"put the cap in a 'private/drop_upload_dircap' file, and delete this option.")
raise OldConfigOptionError("The [drop_upload] section must be renamed to [magic_folder].\n"
"See docs/frontends/magic-folder.rst for more information.")
upload_dircap = self.get_or_create_private_config("drop_upload_dircap")
local_dir_config = self.get_config("drop_upload", "local.directory").decode("utf-8")
if self.get_config("magic_folder", "enabled", False, boolean=True):
#print "magic folder enabled"
upload_dircap = self.get_private_config("magic_folder_dircap")
collective_dircap = self.get_private_config("collective_dircap")
local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
local_dir = abspath_expanduser_unicode(local_dir_config, base=self.basedir)
try:
from allmydata.frontends import drop_upload
dbfile = os.path.join(self.basedir, "private", "magicfolderdb.sqlite")
dbfile = abspath_expanduser_unicode(dbfile)
s = drop_upload.DropUploader(self, upload_dircap, local_dir, dbfile)
s.setServiceParent(self)
s.startService()
dbfile = os.path.join(self.basedir, "private", "magicfolderdb.sqlite")
dbfile = abspath_expanduser_unicode(dbfile)
# start processing the upload queue when we've connected to enough servers
self.connected_enough_d.addCallback(s.ready)
except Exception, e:
self.log("couldn't start drop-uploader: %r", args=(e,))
from allmydata.frontends import magic_folder
s = magic_folder.MagicFolder(self, upload_dircap, local_dir, dbfile)
s.setServiceParent(self)
s.startService()
# start processing the upload queue when we've connected to enough servers
self.connected_enough_d.addCallback(s.ready)
def _check_exit_trigger(self, exit_trigger_file):
if os.path.exists(exit_trigger_file):