mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +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.
|
||||
|
||||
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
|
||||
overwriting), add a "replace=false" argument, as "?t=uri&replace=false". With
|
||||
replace=false, this operation will return an HTTP 409 "Conflict" error if
|
||||
there is already an object at the given location, rather than overwriting the
|
||||
existing object. Note that "true", "t", and "1" are all synonyms for "True",
|
||||
and "false", "f", and "0" are synonyms for "False". the parameter is
|
||||
case-insensitive. If you want this behavior only if there is an existing
|
||||
directory at the same location (that is, you want the operation to return an
|
||||
error if there is a directory at the same name, but to succeed if there is a
|
||||
file), add a "replace=only-files" argument, as "?t=uri&replace=only-files".
|
||||
location. To prevent this (and make the operation return an error instead
|
||||
of overwriting), add a "replace=false" argument, as "?t=uri&replace=false".
|
||||
With replace=false, this operation will return an HTTP 409 "Conflict" error
|
||||
if there is already an object at the given location, rather than
|
||||
overwriting the existing object. To allow the operation to overwrite a
|
||||
file, but return an error when trying to overwrite a directory, use
|
||||
"replace=only-files" (this behavior is closer to the traditional unix "mv"
|
||||
command). Note that "true", "t", and "1" are all synonyms for "True", and
|
||||
"false", "f", and "0" are synonyms for "False", and the parameter is
|
||||
case-insensitive.
|
||||
|
||||
=== 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
|
||||
already exist.
|
||||
|
||||
This accepts the same replace= argument as POST t=upload.
|
||||
|
||||
=== Deleting A Child ===
|
||||
|
||||
POST /uri/$DIRCAP/[SUBDIRS../]?t=delete&name=CHILDNAME
|
||||
|
@ -805,12 +805,14 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("cp", fn1, "tahoe:"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("cp", fn2, "tahoe:"))
|
||||
# do mv file1 file3
|
||||
|
||||
# do mv file1 file3
|
||||
# (we should be able to rename files)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file1", "tahoe:file3"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("OK", out, "mv didn't rename a file"))
|
||||
|
||||
# do mv file3 file2
|
||||
# (This should succeed without issue)
|
||||
d.addCallback(lambda res:
|
||||
@ -818,11 +820,13 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# Out should contain "OK" to show that the transfer worked.
|
||||
d.addCallback(lambda (rc,out,err):
|
||||
self.failUnlessIn("OK", out, "mv didn't output OK after mving"))
|
||||
|
||||
# Next, make a remote directory.
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mkdir", "tahoe: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)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file2", "tahoe:directory"))
|
||||
@ -830,6 +834,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessIn(
|
||||
"Error: You can't overwrite a directory with a file", err,
|
||||
"mv shouldn't overwrite directories" ))
|
||||
|
||||
# mv file2 directory/
|
||||
# (should succeed by making file2 a child node of directory)
|
||||
d.addCallback(lambda res:
|
||||
@ -850,6 +855,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("404", err,
|
||||
"mv left the source file intact"))
|
||||
|
||||
# Let's build:
|
||||
# directory/directory2/some_file
|
||||
# directory3
|
||||
@ -859,6 +865,7 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("cp", fn2, "tahoe:directory/directory2/some_file"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mkdir", "tahoe:directory3"))
|
||||
|
||||
# Let's now try to mv directory/directory2/some_file to
|
||||
# directory3/some_file
|
||||
d.addCallback(lambda res:
|
||||
|
@ -22,7 +22,7 @@ def boolean_of_arg(arg):
|
||||
return arg.lower() in ("true", "t", "1", "on")
|
||||
|
||||
def parse_replace_arg(replace):
|
||||
if replace == "only-files":
|
||||
if replace.lower() == "only-files":
|
||||
return replace
|
||||
else:
|
||||
return boolean_of_arg(replace)
|
||||
|
Loading…
Reference in New Issue
Block a user