mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-04 16:50:57 +00:00
apply review feedback
This commit is contained in:
parent
275ddb93cc
commit
be5d07a70a
@ -24,6 +24,10 @@ class FilenameWithTrailingSlashError(TahoeError):
|
|||||||
def __init__(self, name, quotefn=quote_output):
|
def __init__(self, name, quotefn=quote_output):
|
||||||
TahoeError.__init__(self, "source '%s' is not a directory, but ends with a slash" % quotefn(name))
|
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):
|
def GET_to_file(url):
|
||||||
resp = do_http("GET", url)
|
resp = do_http("GET", url)
|
||||||
@ -507,8 +511,8 @@ class Copier:
|
|||||||
for ss in source_specs:
|
for ss in source_specs:
|
||||||
try:
|
try:
|
||||||
si = self.get_source_info(ss)
|
si = self.get_source_info(ss)
|
||||||
except FilenameWithTrailingSlashError:
|
except FilenameWithTrailingSlashError as e:
|
||||||
self.to_stderr("source is not a directory, but ends with a slash")
|
self.to_stderr(str(e))
|
||||||
return 1
|
return 1
|
||||||
precondition(isinstance(si, FileSources + DirectorySources), si)
|
precondition(isinstance(si, FileSources + DirectorySources), si)
|
||||||
sources.append(si)
|
sources.append(si)
|
||||||
@ -643,8 +647,10 @@ class Copier:
|
|||||||
t = LocalDirectorySource(self.progress, pathname, name)
|
t = LocalDirectorySource(self.progress, pathname, name)
|
||||||
else:
|
else:
|
||||||
if had_trailing_slash:
|
if had_trailing_slash:
|
||||||
raise FilenameWithTrailingSlashError(source_spec)
|
raise FilenameWithTrailingSlashError(source_spec,
|
||||||
assert os.path.isfile(pathname)
|
quotefn=quote_local_unicode_path)
|
||||||
|
if not os.path.isfile(pathname):
|
||||||
|
raise WeirdSourceError(pathname)
|
||||||
t = LocalFileSource(pathname, name) # non-empty
|
t = LocalFileSource(pathname, name) # non-empty
|
||||||
else:
|
else:
|
||||||
# this is a tahoe object
|
# this is a tahoe object
|
||||||
|
@ -949,7 +949,8 @@ class CopyOut(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
return set(["E6-MANYONE"])
|
return set(["E6-MANYONE"])
|
||||||
if err == "target is not a directory, but ends with a slash":
|
if err == "target is not a directory, but ends with a slash":
|
||||||
return set(["E7-BADSLASH"])
|
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"])
|
return set(["E8-BADSLASH"])
|
||||||
self.fail("unrecognized error ('%s') %s" % (case, res))
|
self.fail("unrecognized error ('%s') %s" % (case, res))
|
||||||
d.addCallback(_check)
|
d.addCallback(_check)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user