mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 08:25:35 +00:00
Touch up #705 changes:
webapi.txt: clarify replace=only-files argument, mention replace= on POST t=uri test_cli.py: insert whitespace between logical operations web.common.parse_replace_arg: make it case-insensitive, to match the docs
This commit is contained in:
parent
fed83b2d52
commit
bf1e61c8f3
@ -566,16 +566,16 @@ PUT /uri/$DIRCAP/[SUBDIRS../]CHILDNAME?t=uri
|
|||||||
request, and this same cap is returned in the response body.
|
request, and this same cap is returned in the response body.
|
||||||
|
|
||||||
The default behavior is to overwrite any existing object at the same
|
The default behavior is to overwrite any existing object at the same
|
||||||
location. To prevent this (and make the operation return an error instead of
|
location. To prevent this (and make the operation return an error instead
|
||||||
overwriting), add a "replace=false" argument, as "?t=uri&replace=false". With
|
of overwriting), add a "replace=false" argument, as "?t=uri&replace=false".
|
||||||
replace=false, this operation will return an HTTP 409 "Conflict" error if
|
With replace=false, this operation will return an HTTP 409 "Conflict" error
|
||||||
there is already an object at the given location, rather than overwriting the
|
if there is already an object at the given location, rather than
|
||||||
existing object. Note that "true", "t", and "1" are all synonyms for "True",
|
overwriting the existing object. To allow the operation to overwrite a
|
||||||
and "false", "f", and "0" are synonyms for "False". the parameter is
|
file, but return an error when trying to overwrite a directory, use
|
||||||
case-insensitive. If you want this behavior only if there is an existing
|
"replace=only-files" (this behavior is closer to the traditional unix "mv"
|
||||||
directory at the same location (that is, you want the operation to return an
|
command). Note that "true", "t", and "1" are all synonyms for "True", and
|
||||||
error if there is a directory at the same name, but to succeed if there is a
|
"false", "f", and "0" are synonyms for "False", and the parameter is
|
||||||
file), add a "replace=only-files" argument, as "?t=uri&replace=only-files".
|
case-insensitive.
|
||||||
|
|
||||||
=== Deleting a File or Directory ===
|
=== Deleting a File or Directory ===
|
||||||
|
|
||||||
@ -822,6 +822,8 @@ POST /uri/$DIRCAP/[SUBDIRS../]?t=uri&name=CHILDNAME&uri=CHILDCAP
|
|||||||
/uri/$DIRCAP/[SUBDIRS../]", it is likely that the parent directory will
|
/uri/$DIRCAP/[SUBDIRS../]", it is likely that the parent directory will
|
||||||
already exist.
|
already exist.
|
||||||
|
|
||||||
|
This accepts the same replace= argument as POST t=upload.
|
||||||
|
|
||||||
=== Deleting A Child ===
|
=== Deleting A Child ===
|
||||||
|
|
||||||
POST /uri/$DIRCAP/[SUBDIRS../]?t=delete&name=CHILDNAME
|
POST /uri/$DIRCAP/[SUBDIRS../]?t=delete&name=CHILDNAME
|
||||||
|
@ -805,12 +805,14 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
self.do_cli("cp", fn1, "tahoe:"))
|
self.do_cli("cp", fn1, "tahoe:"))
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.do_cli("cp", fn2, "tahoe:"))
|
self.do_cli("cp", fn2, "tahoe:"))
|
||||||
|
|
||||||
# do mv file1 file3
|
# do mv file1 file3
|
||||||
# (we should be able to rename files)
|
# (we should be able to rename files)
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.do_cli("mv", "tahoe:file1", "tahoe:file3"))
|
self.do_cli("mv", "tahoe:file1", "tahoe:file3"))
|
||||||
d.addCallback(lambda (rc, out, err):
|
d.addCallback(lambda (rc, out, err):
|
||||||
self.failUnlessIn("OK", out, "mv didn't rename a file"))
|
self.failUnlessIn("OK", out, "mv didn't rename a file"))
|
||||||
|
|
||||||
# do mv file3 file2
|
# do mv file3 file2
|
||||||
# (This should succeed without issue)
|
# (This should succeed without issue)
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
@ -818,9 +820,11 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
# Out should contain "OK" to show that the transfer worked.
|
# Out should contain "OK" to show that the transfer worked.
|
||||||
d.addCallback(lambda (rc,out,err):
|
d.addCallback(lambda (rc,out,err):
|
||||||
self.failUnlessIn("OK", out, "mv didn't output OK after mving"))
|
self.failUnlessIn("OK", out, "mv didn't output OK after mving"))
|
||||||
|
|
||||||
# Next, make a remote directory.
|
# Next, make a remote directory.
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.do_cli("mkdir", "tahoe:directory"))
|
self.do_cli("mkdir", "tahoe:directory"))
|
||||||
|
|
||||||
# mv file2 directory
|
# mv file2 directory
|
||||||
# (should fail with a descriptive error message; the CLI mv
|
# (should fail with a descriptive error message; the CLI mv
|
||||||
# client should support this)
|
# client should support this)
|
||||||
@ -830,6 +834,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
self.failUnlessIn(
|
self.failUnlessIn(
|
||||||
"Error: You can't overwrite a directory with a file", err,
|
"Error: You can't overwrite a directory with a file", err,
|
||||||
"mv shouldn't overwrite directories" ))
|
"mv shouldn't overwrite directories" ))
|
||||||
|
|
||||||
# mv file2 directory/
|
# mv file2 directory/
|
||||||
# (should succeed by making file2 a child node of directory)
|
# (should succeed by making file2 a child node of directory)
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
@ -850,6 +855,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
d.addCallback(lambda (rc, out, err):
|
d.addCallback(lambda (rc, out, err):
|
||||||
self.failUnlessIn("404", err,
|
self.failUnlessIn("404", err,
|
||||||
"mv left the source file intact"))
|
"mv left the source file intact"))
|
||||||
|
|
||||||
# Let's build:
|
# Let's build:
|
||||||
# directory/directory2/some_file
|
# directory/directory2/some_file
|
||||||
# directory3
|
# directory3
|
||||||
@ -859,6 +865,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
self.do_cli("cp", fn2, "tahoe:directory/directory2/some_file"))
|
self.do_cli("cp", fn2, "tahoe:directory/directory2/some_file"))
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
self.do_cli("mkdir", "tahoe:directory3"))
|
self.do_cli("mkdir", "tahoe:directory3"))
|
||||||
|
|
||||||
# Let's now try to mv directory/directory2/some_file to
|
# Let's now try to mv directory/directory2/some_file to
|
||||||
# directory3/some_file
|
# directory3/some_file
|
||||||
d.addCallback(lambda res:
|
d.addCallback(lambda res:
|
||||||
|
@ -22,7 +22,7 @@ def boolean_of_arg(arg):
|
|||||||
return arg.lower() in ("true", "t", "1", "on")
|
return arg.lower() in ("true", "t", "1", "on")
|
||||||
|
|
||||||
def parse_replace_arg(replace):
|
def parse_replace_arg(replace):
|
||||||
if replace == "only-files":
|
if replace.lower() == "only-files":
|
||||||
return replace
|
return replace
|
||||||
else:
|
else:
|
||||||
return boolean_of_arg(replace)
|
return boolean_of_arg(replace)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user