mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 19:34:18 +00:00
CLI: add put --mutable, enhance ls to show mutable vs immutable as rw/r-
This commit is contained in:
parent
e323019708
commit
e889463f0c
@ -114,6 +114,10 @@ class GetOptions(VDriveOptions):
|
||||
will be written to stdout."""
|
||||
|
||||
class PutOptions(VDriveOptions):
|
||||
optFlags = [
|
||||
("mutable", "m", "Create a mutable file instead of an immutable one."),
|
||||
]
|
||||
|
||||
def parseArgs(self, arg1=None, arg2=None):
|
||||
# cat FILE > tahoe put # create unlinked file from stdin
|
||||
# cat FILE > tahoe put FOO # create tahoe:FOO from stdin
|
||||
@ -229,6 +233,7 @@ def put(config, stdout, stderr, stdin=sys.stdin):
|
||||
config.aliases,
|
||||
config.from_file,
|
||||
config.to_file,
|
||||
config['mutable'],
|
||||
verbosity,
|
||||
stdin, stdout, stderr)
|
||||
return rc
|
||||
|
@ -36,6 +36,8 @@ def list(nodeurl, aliases, where, config, stdout, stderr):
|
||||
childtype = child[0]
|
||||
ctime = child[1]["metadata"].get("ctime")
|
||||
mtime = child[1]["metadata"].get("mtime")
|
||||
rw_uri = child[1].get("rw_uri")
|
||||
ro_uri = child[1].get("ro_uri")
|
||||
if ctime:
|
||||
# match for formatting that GNU 'ls' does
|
||||
if (now - ctime) > 6*30*24*60*60:
|
||||
@ -47,21 +49,32 @@ def list(nodeurl, aliases, where, config, stdout, stderr):
|
||||
else:
|
||||
ctime_s = "-"
|
||||
if childtype == "dirnode":
|
||||
t = "d---------"
|
||||
t0 = "d"
|
||||
size = "-"
|
||||
classify = "/"
|
||||
elif childtype == "filenode":
|
||||
t = "----------"
|
||||
t0 = "-"
|
||||
size = child[1]['size']
|
||||
classify = ""
|
||||
if "rw_uri" in child[1]:
|
||||
classify = "*" # mutable
|
||||
else:
|
||||
t0 = "?"
|
||||
size = "?"
|
||||
classify = "?"
|
||||
t1 = "-"
|
||||
if ro_uri:
|
||||
t1 = "r"
|
||||
t2 = "-"
|
||||
if rw_uri:
|
||||
t2 = "w"
|
||||
t3 = "-"
|
||||
if childtype == "dirnode":
|
||||
t3 = "x"
|
||||
|
||||
uri = child[1].get("rw_uri", child[1].get("ro_uri", "-"))
|
||||
uri = rw_uri or ro_uri
|
||||
|
||||
line = []
|
||||
if config["long"]:
|
||||
line.append("%s %10s %12s" % (t, size, ctime_s))
|
||||
line.append("%s %10s %12s" % (t0+t1+t2+t3, size, ctime_s))
|
||||
if config["uri"]:
|
||||
line.append(uri)
|
||||
line.append(name)
|
||||
|
@ -4,8 +4,8 @@ import urllib
|
||||
from allmydata.scripts.common_http import do_http
|
||||
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
|
||||
|
||||
def put(nodeurl, aliases, from_file, to_file, verbosity,
|
||||
stdin, stdout, stderr):
|
||||
def put(nodeurl, aliases, from_file, to_file, mutable,
|
||||
verbosity, stdin, stdout, stderr):
|
||||
"""
|
||||
@param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose
|
||||
|
||||
@ -20,6 +20,8 @@ def put(nodeurl, aliases, from_file, to_file, verbosity,
|
||||
url += escape_path(path)
|
||||
else:
|
||||
url = nodeurl + "uri"
|
||||
if mutable:
|
||||
url += "?mutable=true"
|
||||
if from_file:
|
||||
infileobj = open(from_file, "rb")
|
||||
else:
|
||||
|
@ -1604,6 +1604,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
|
||||
d.addCallback(run, "put", files[1], "subdir/tahoe-file1")
|
||||
# tahoe put bar tahoe:FOO
|
||||
d.addCallback(run, "put", files[2], "tahoe:file2")
|
||||
d.addCallback(run, "put", "--mutable", files[3], "tahoe:file3")
|
||||
|
||||
def _put_from_stdin(res, data, *args):
|
||||
args = nodeargs + list(args)
|
||||
@ -1629,7 +1630,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
|
||||
"tahoe:from-stdin")
|
||||
|
||||
d.addCallback(run, "ls")
|
||||
d.addCallback(_check_ls, ["tahoe-file0", "file2", "subdir",
|
||||
d.addCallback(_check_ls, ["tahoe-file0", "file2", "file3", "subdir",
|
||||
"tahoe-file-stdin", "from-stdin"])
|
||||
d.addCallback(run, "ls", "subdir")
|
||||
d.addCallback(_check_ls, ["tahoe-file1"])
|
||||
@ -1670,7 +1671,10 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
|
||||
lines = out.split("\n")
|
||||
for l in lines:
|
||||
if "tahoe-file-stdin" in l:
|
||||
self.failUnless(l.startswith("-r-- "), l)
|
||||
self.failUnless(" %d " % len(STDIN_DATA) in l)
|
||||
if "file3" in l:
|
||||
self.failUnless(l.startswith("-rw- "), l) # mutable
|
||||
d.addCallback(_check_ls_l)
|
||||
|
||||
d.addCallback(run, "mv", "tahoe-file-stdin", "tahoe-moved")
|
||||
|
Loading…
x
Reference in New Issue
Block a user