Exemplo n.º 1
0
func main() {
	flag.Parse()
	files := flag.Args()
	if len(files) == 0 {
		files = util.PipedStdin()
	}

	m, err := mount.Load("./.mount")
	if err != nil {
		fmt.Println("Failed to load mount file: ", err)
		return
	}

	for _, path := range files {
		if mm, err := m.GetMeta(path); err == nil {
			if *hide {
				mm.Hidden = true
			}
			if *pth != "NOPATH" {
				mm.Path = *pth
			}
			err = m.SetMeta(path, mm)
			if err != nil {
				fmt.Println("Could not update file '" + path + "'")
			}
		}
	}
}
Exemplo n.º 2
0
func main() {
	flag.Parse()
	url := flag.Arg(0)

	refs := []string{}
	if len(flag.Args()) > 1 {
		refs = flag.Args()[1:]
	} else {
		piped := util.PipedStdin()
		url = piped[0]
		if len(piped) > 1 {
			refs = piped[1:]
		}
	}

	tmp := strings.Split(url, "@")
	userPass := strings.Split(tmp[0], ":")
	if len(userPass) != 2 || len(tmp) != 2 {
		fmt.Println("Invalid blobserver address")
		return
	}

	m := mount.New(mountPath)
	m.ConfigClient(userPass[0], userPass[1], tmp[1])
	m.Root, _ = filepath.Abs(*root)
	m.Prefix = *prefix

	err := m.Unpack(refs...)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = m.Save(filepath.Join(*root, ".mount"))
	if err != nil {
		fmt.Println(err)
		return
	}
}