drop-upload: rename the 'upload.uri' parameter to 'upload.dircap', and a couple of cleanups to error messages. refs #1429

I rerecorded this patch, originally by David-Sarah, to use "darcs replace" instead of editing to do the renames. This uncovered one missed rename in Client.init_drop_uploader. (Which also means that code isn't exercised by the current unit tests.)
refs #1429
This commit is contained in:
Zooko O'Whielacronx 2011-08-09 15:05:08 -07:00
parent 5633375d26
commit b7683d9b83
4 changed files with 19 additions and 18 deletions

View File

@ -43,14 +43,14 @@ gateway's ``tahoe.cfg`` file.
``enabled = (boolean, optional)``
If this is ``True``, drop-upload will be enabled (provided that the
``upload.uri`` and ``local.directory`` fields are also set). The default
value is ``False``.
``upload.dircap`` and ``local.directory`` fields are also set). The
default value is ``False``.
``upload.uri = (URI)``
``upload.dircap = (directory writecap)``
This is the Tahoe URI of an existing mutable directory to be used as
the target of uploads. It must be the full URI of the directory
(starting with ``URI:DIR2:``), and cannot include an alias or path.
This is a writecap pointing to an existing mutable directory to be used
as the target of uploads. It will start with ``URI:DIR2:``, and cannot
include an alias or path.
``local.directory = (UTF-8 path)``

View File

@ -424,19 +424,19 @@ class Client(node.Node, pollmixin.PollMixin):
def init_drop_uploader(self):
if self.get_config("drop_upload", "enabled", False, boolean=True):
upload_uri = self.get_config("drop_upload", "upload.uri", None)
upload_dircap = self.get_config("drop_upload", "upload.dircap", None)
local_dir_utf8 = self.get_config("drop_upload", "local.directory", None)
if upload_uri and local_dir_utf8:
if upload_dircap and local_dir_utf8:
try:
from allmydata.frontends import drop_upload
s = drop_upload.DropUploader(self, upload_uri, local_dir_utf8)
s = drop_upload.DropUploader(self, upload_dircap, local_dir_utf8)
s.setServiceParent(self)
s.start()
except Exception, e:
self.log("couldn't start drop-uploader: %r", args=(e,))
else:
self.log("couldn't start drop-uploader: upload.uri or local.directory not specified")
self.log("couldn't start drop-uploader: upload.dircap or local.directory not specified")
def _check_hotline(self, hotline_file):
if os.path.exists(hotline_file):

View File

@ -13,7 +13,7 @@ from allmydata.immutable.upload import FileName
class DropUploader(service.MultiService):
def __init__(self, client, upload_uri, local_dir_utf8, inotify=None):
def __init__(self, client, upload_dircap, local_dir_utf8, inotify=None):
service.MultiService.__init__(self)
try:
@ -23,7 +23,8 @@ class DropUploader(service.MultiService):
else:
local_dir = local_dir_u.encode(get_filesystem_encoding())
except (UnicodeEncodeError, UnicodeDecodeError):
raise AssertionError("The drop-upload path %s was not valid UTF-8 or could not be represented in the filesystem encoding."
raise AssertionError("The '[drop_upload] local.directory' parameter %s was not valid UTF-8 or "
"could not be represented in the filesystem encoding."
% quote_output(local_dir_utf8))
self._client = client
@ -38,12 +39,12 @@ class DropUploader(service.MultiService):
if not self._local_path.isdir():
raise AssertionError("The drop-upload local path %r was not an existing directory." % quote_output(local_dir_u))
# TODO: allow a path rather than an URI.
self._parent = self._client.create_node_from_uri(upload_uri)
# TODO: allow a path rather than a cap URI.
self._parent = self._client.create_node_from_uri(upload_dircap)
if not IDirectoryNode.providedBy(self._parent):
raise AssertionError("The drop-upload remote URI is not a directory URI.")
raise AssertionError("The '[drop_upload] upload.dircap' parameter does not refer to a directory.")
if self._parent.is_unknown() or self._parent.is_readonly():
raise AssertionError("The drop-upload remote URI does not refer to a writeable directory.")
raise AssertionError("The '[drop_upload] upload.dircap' parameter is not a writecap to a directory.")
self._uploaded_callback = lambda ign: None

View File

@ -155,8 +155,8 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
c.write("[drop_upload]\n")
c.write("# Shall this node automatically upload files created or modified in a local directory?\n")
c.write("enabled = false\n")
c.write("# This must be an URI for a writeable directory.\n")
c.write("upload.uri =\n")
c.write("# This must be a mutable directory writecap.\n")
c.write("upload.dircap =\n")
c.write("local.directory = ~/drop_upload\n")
c.write("\n")