]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/frontends/drop_upload.py
drop-upload.py: fix error messages.
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / frontends / drop_upload.py
index c949b4d77a2c1e6e0679a9b6d9603547576ae745..425007712d83fde810d34138c3d016c5def27c83 100644 (file)
@@ -1,5 +1,5 @@
 
-import os, sys
+import sys
 
 from twisted.internet import defer
 from twisted.python.filepath import FilePath
@@ -9,15 +9,18 @@ from foolscap.api import eventually
 from allmydata.interfaces import IDirectoryNode
 
 from allmydata.util.encodingutil import quote_output, get_filesystem_encoding
+from allmydata.util.fileutil import abspath_expanduser_unicode
 from allmydata.immutable.upload import FileName
 
 
 class DropUploader(service.MultiService):
+    name = 'drop-upload'
+
     def __init__(self, client, upload_dircap, local_dir_utf8, inotify=None):
         service.MultiService.__init__(self)
 
         try:
-            local_dir_u = os.path.expanduser(local_dir_utf8.decode('utf-8'))
+            local_dir_u = abspath_expanduser_unicode(local_dir_utf8.decode('utf-8'))
             if sys.platform == "win32":
                 local_dir = local_dir_u
             else:
@@ -36,15 +39,17 @@ class DropUploader(service.MultiService):
             from twisted.internet import inotify
         self._inotify = inotify
 
+        if not self._local_path.exists():
+            raise AssertionError("The '[drop_upload] local.directory' parameter was %s but there is no directory at that location." % quote_output(local_dir_u))
         if not self._local_path.isdir():
-            raise AssertionError("The drop-upload local path %r was not an existing directory." % quote_output(local_dir_u))
+            raise AssertionError("The '[drop_upload] local.directory' parameter was %s but the thing at that location is not a directory." % quote_output(local_dir_u))
 
         # 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] upload.dircap' parameter does not refer to a directory.")
+            raise AssertionError("The URI in 'private/drop_upload_dircap' does not refer to a directory.")
         if self._parent.is_unknown() or self._parent.is_readonly():
-            raise AssertionError("The '[drop_upload] upload.dircap' parameter is not a writecap to a directory.")
+            raise AssertionError("The URI in 'private/drop_upload_dircap' is not a writecap to a directory.")
 
         self._uploaded_callback = lambda ign: None
 
@@ -57,7 +62,8 @@ class DropUploader(service.MultiService):
         mask = inotify.IN_CLOSE_WRITE | inotify.IN_MOVED_TO | inotify.IN_ONLYDIR
         self._notifier.watch(self._local_path, mask=mask, callbacks=[self._notify])
 
-    def start(self):
+    def startService(self):
+        service.MultiService.startService(self)
         d = self._notifier.startReading()
         self._stats_provider.count('drop_upload.dirs_monitored', 1)
         return d