]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
apply review feedback
authorBrian Warner <warner@lothar.com>
Mon, 4 May 2015 05:03:25 +0000 (22:03 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 4 May 2015 05:14:36 +0000 (22:14 -0700)
src/allmydata/scripts/tahoe_cp.py
src/allmydata/test/test_cli_cp.py

index 7c3026218563b7ca085bcd8cb8c3f8e883048ec4..b603d6ba01193c67be16fb74da19ed9b5d61a162 100644 (file)
@@ -24,6 +24,10 @@ class FilenameWithTrailingSlashError(TahoeError):
     def __init__(self, name, quotefn=quote_output):
         TahoeError.__init__(self, "source '%s' is not a directory, but ends with a slash" % quotefn(name))
 
+class WeirdSourceError(TahoeError):
+    def __init__(self, absname):
+        quoted = quote_local_unicode_path(absname)
+        TahoeError.__init__(self, "source '%s' is neither a file nor a directory, I can't handle it" % quoted)
 
 def GET_to_file(url):
     resp = do_http("GET", url)
@@ -507,8 +511,8 @@ class Copier:
         for ss in source_specs:
             try:
                 si = self.get_source_info(ss)
-            except FilenameWithTrailingSlashError:
-                self.to_stderr("source is not a directory, but ends with a slash")
+            except FilenameWithTrailingSlashError as e:
+                self.to_stderr(str(e))
                 return 1
             precondition(isinstance(si, FileSources + DirectorySources), si)
             sources.append(si)
@@ -643,8 +647,10 @@ class Copier:
                 t = LocalDirectorySource(self.progress, pathname, name)
             else:
                 if had_trailing_slash:
-                    raise FilenameWithTrailingSlashError(source_spec)
-                assert os.path.isfile(pathname)
+                    raise FilenameWithTrailingSlashError(source_spec,
+                                                         quotefn=quote_local_unicode_path)
+                if not os.path.isfile(pathname):
+                    raise WeirdSourceError(pathname)
                 t = LocalFileSource(pathname, name) # non-empty
         else:
             # this is a tahoe object
index 03abcc4595cb344122ecec23b2b1fe68e462d369..65f4e4a1578d0daf2dbadf364eb76f0eedcb8924 100644 (file)
@@ -949,7 +949,8 @@ class CopyOut(GridTestMixin, CLITestMixin, unittest.TestCase):
                     return set(["E6-MANYONE"])
                 if err == "target is not a directory, but ends with a slash":
                     return set(["E7-BADSLASH"])
-                if err == "source is not a directory, but ends with a slash":
+                if (err.startswith("source ") and
+                    "is not a directory, but ends with a slash" in err):
                     return set(["E8-BADSLASH"])
             self.fail("unrecognized error ('%s') %s" % (case, res))
         d.addCallback(_check)