Beispiel #1
0
func moveTo(client *hdfs.Client, source, dest string, force bool) {
	if force {
		err := client.Remove(dest)
		if err != nil && !os.IsNotExist(err) {
			fatal(err)
		}
	}

	err := client.Rename(source, dest)
	if err != nil {
		fatal(err)
	}
}
Beispiel #2
0
func moveTo(client *hdfs.Client, source, dest string, force bool) {
	resp, err := client.Stat(dest)
	if force {
		if err == nil && resp.IsDir() {
			if err = client.Remove(dest); err != nil {
				fatal(err)
			}
		}
	} else if err == nil {
		fatal(&os.PathError{"rename", dest, os.ErrExist})
	}

	err = client.Rename(source, dest)
	if err != nil {
		fatal(err)
	}
}