Esempio n. 1
0
// Dial the server for this dir (if not already dialed) and return it,
// the dir addr is updated.
func DirFs(d zx.Dir) (zx.Fs, error) {
	switch p := d.Proto(); p {
	case "lfs":
		addr := d["addr"]
		toks := strings.Split(d["addr"], "!") // lfs!root!/path
		if len(toks) != 3 {
			return nil, fmt.Errorf("ns: no zux tree for addr %q", addr)
		}
		fullpath := fpath.Join(toks[1], toks[2])
		fs, root, rel := Lfs(fullpath)
		if fs == nil {
			return nil, fmt.Errorf("ns: no zux tree for addr %q", addr)
		}
		d["addr"] = "lfs!" + root + "!" + rel
		return fs, nil
	case "zx":
		addr := d.SAddr()
		if len(addr) < 3 {
			panic("DirFs bug")
		}
		addr = addr[3:] // remove zx!
		// rzx does cache dials, no need to do it again here.
		return rzx.Dial(addr, auth.TLSclient)
	default:
		return nil, fmt.Errorf("ns: no tree for addr %q", d["addr"])
	}
}
Esempio n. 2
0
func mv1(src, dst zx.Dir) error {
	cmd.VWarn("%s %s", src["Upath"], dst["Upath"])
	cmd.Dprintf("mv1: %s %s %s %s\n", src.SAddr(), src["Rpath"], dst.SAddr(), dst["Rpath"])
	if dry {
		return nil
	}
	return cmd.Move(src["path"], dst["path"])
}