def getSynopsis(self):
return "%s mv FROM TO" % (os.path.basename(sys.argv[0]),)
+class LnOptions(VDriveOptions):
+ def parseArgs(self, frompath, topath):
+ self.from_file = frompath
+ self.to_file = topath
+
+ def getSynopsis(self):
+ return "%s ln FROM TO" % (os.path.basename(sys.argv[0]),)
+
class WebopenOptions(VDriveOptions):
def parseArgs(self, vdrive_pathname=""):
self['vdrive_pathname'] = vdrive_pathname
["put", None, PutOptions, "Upload a file into the virtual drive."],
["rm", None, RmOptions, "Unlink a file or directory in the virtual drive."],
["mv", None, MvOptions, "Move a file within the virtual drive."],
+ ["ln", None, LnOptions, "Make an additional link to an existing file."],
["webopen", None, WebopenOptions, "Open a webbrowser to the root_dir"],
["repl", None, ReplOptions, "Open a python interpreter"],
]
config.aliases,
config.from_file,
config.to_file,
- stdout, stderr)
+ stdout, stderr,
+ mode="move")
+ return rc
+
+def ln(config, stdout, stderr):
+ from allmydata.scripts import tahoe_mv
+ rc = tahoe_mv.mv(config['node-url'],
+ config.aliases,
+ config.from_file,
+ config.to_file,
+ stdout, stderr,
+ mode="link")
return rc
def webopen(config, stdout, stderr):
"put": put,
"rm": rm,
"mv": mv,
+ "ln": ln,
"webopen": webopen,
"repl": repl,
}
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
from allmydata.scripts.common_http import do_http
-def mv(nodeurl, aliases, from_file, to_file, stdout, stderr):
+# this script is used for both 'mv' and 'ln'
+
+def mv(nodeurl, aliases, from_file, to_file, stdout, stderr, mode="move"):
if nodeurl[-1] != "/":
nodeurl += "/"
rootcap, path = get_alias(aliases, from_file, DEFAULT_ALIAS)
if not re.search(r'^2\d\d$', str(status)):
print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
print >>stderr, resp.read()
- print >>stderr, "NOT removing the original"
+ if mode == "move":
+ print >>stderr, "NOT removing the original"
return
- # now remove the original
- resp = do_http("DELETE", from_url)
- if not re.search(r'^2\d\d$', str(status)):
- print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
- print >>stderr, resp.read()
+ if mode == "move":
+ # now remove the original
+ resp = do_http("DELETE", from_url)
+ if not re.search(r'^2\d\d$', str(status)):
+ print >>stderr, "error, got %s %s" % (resp.status, resp.reason)
+ print >>stderr, resp.read()
print >>stdout, "OK"
return
d.addCallback(run, "ls")
d.addCallback(_check_ls, ["tahoe-moved"], ["tahoe-file-stdin"])
+ d.addCallback(run, "ln", "tahoe-moved", "newlink")
+ d.addCallback(run, "ls")
+ d.addCallback(_check_ls, ["tahoe-moved", "newlink"])
+
# tahoe_ls doesn't currently handle the error correctly: it tries to
# JSON-parse a traceback.
## def _ls_missing(res):