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
config.aliases,
config.from_file,
config.to_file,
+ config['mutable'],
verbosity,
stdin, stdout, stderr)
return rc
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:
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)
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
url += escape_path(path)
else:
url = nodeurl + "uri"
+ if mutable:
+ url += "?mutable=true"
if from_file:
infileobj = open(from_file, "rb")
else:
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)
"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"])
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")