Ejemplo n.º 1
0
func killdir(dir string, recurse bool) error {
	d, err := anchorfs.OpenDir(dir)
	if err != nil {
		log.Printf("Problem opening directory (%s)", err)
		return err
	}

	// Recurse
	if recurse {
		dirs, err := d.Dirs()
		if err != nil {
			log.Printf("Problem listing directories in %s (%s)", dir, err)
			return err
		}
		for _, dd := range dirs {
			if err = killdir(path.Join(dir, dd), recurse); err != nil {
				return err
			}
		}
	}

	// Kill files
	_, files, err := d.Files()
	if err != nil {
		log.Printf("Problem listing files in %s (%s)", dir, err)
		return err
	}
	for _, f := range files {
		if err = worker.Kill(f.Owner()); err != nil {
			log.Printf("Problem killing %s (%s)", f.Owner(), err)
			return err
		} else {
			log.Printf("Killed %s", f.Owner())
		}
	}

	return nil
}
Ejemplo n.º 2
0
func main() {
	flag.Usage = usage
	flag.Parse()

	anchor, file, recurse, err := parse(flag.Arg(0))
	if err != nil {
		usage()
	}
	if file {
		f, err := anchorfs.OpenFile(anchor)
		if err != nil {
			log.Printf("Problem opening (%s)", err)
			os.Exit(1)
		}
		if err = worker.Kill(f.Owner()); err != nil {
			log.Printf("Problem killing (%s)", err)
			os.Exit(1)
		}
		os.Exit(0)
	}
	if err = killdir(anchor, recurse); err != nil {
		os.Exit(1)
	}
}
Ejemplo n.º 3
0
func (r *Runtime) Kill(addr circuit.Addr) error {
	return worker.Kill(addr)
}