Ejemplo n.º 1
0
Archivo: main.go Proyecto: xert/gdriver
func main() {
	var accountFrom string

	if len(os.Args) < 2 {
		usage()
	}

	accountFrom = os.Args[1]

	ctx := context.Background()

	b, err := ioutil.ReadFile(gdrive.FileClientSecret)
	if err != nil {
		log.Fatalf("Unable to read client secret file: %v", err)
	}

	config, err := google.ConfigFromJSON(b, drive.DriveScope)
	if err != nil {
		log.Fatalf("Unable to parse client secret file to config: %v", err)
	}
	client := gdrive.GetClient(ctx, config)

	srv, err := drive.New(client)
	if err != nil {
		log.Fatalf("Unable to retrieve drive Client %v", err)
	}

	workExists, err := util.FileExists(workDir)
	if err != nil {
		log.Fatal(err.Error())
	}

	if !workExists {
		err = fmt.Errorf("Working directory %s does not exist.\nUse %s prepare to create one", workDir, filepath.Base(os.Args[0]))
	} else {
		err = migrate(srv, accountFrom)
	}

	if err != nil {
		log.Fatal(err.Error())
	}

}
Ejemplo n.º 2
0
Archivo: main.go Proyecto: xert/gdriver
func main() {
	var id1, id2 string

	if len(os.Args) < 2 {
		usage()
	}

	if len(os.Args) != 3 {
		usage()
	}
	id1 = os.Args[1]
	id2 = os.Args[2]

	ctx := context.Background()

	b, err := ioutil.ReadFile(gdrive.FileClientSecret)
	if err != nil {
		log.Fatalf("Unable to read client secret file: %v", err)
	}

	config, err := google.ConfigFromJSON(b, drive.DriveScope)
	if err != nil {
		log.Fatalf("Unable to parse client secret file to config: %v", err)
	}
	client := gdrive.GetClient(ctx, config)

	srv, err := drive.New(client)
	if err != nil {
		log.Fatalf("Unable to retrieve drive Client %v", err)
	}

	err = compare(srv, id1, id2)

	if err != nil {
		log.Fatal(err.Error())
	}

}
Ejemplo n.º 3
0
Archivo: main.go Proyecto: xert/gdriver
func main() {
	var accountFrom string
	var accountTo string

	if len(os.Args) < 3 {
		usage()
	}

	accountFrom = os.Args[1]
	accountTo = os.Args[2]

	ctx := context.Background()

	b, err := ioutil.ReadFile(gdrive.FileClientSecret)
	if err != nil {
		log.Fatalf("Unable to read client secret file: %v", err)
	}

	config, err := google.ConfigFromJSON(b, drive.DriveScope)
	if err != nil {
		log.Fatalf("Unable to parse client secret file to config: %v", err)
	}
	client := gdrive.GetClient(ctx, config)

	srv, err := drive.New(client)
	if err != nil {
		log.Fatalf("Unable to retrieve drive Client %v", err)
	}

	log.Printf("Sharing files owned by %s to %s", accountFrom, accountTo)

	err = share(srv, accountFrom, accountTo)

	if err != nil {
		log.Fatal(err.Error())
	}

}
Ejemplo n.º 4
0
Archivo: main.go Proyecto: xert/gdriver
func main() {
	var account string

	if len(os.Args) < 2 {
		usage()
	}

	account = os.Args[1]

	ctx := context.Background()

	b, err := ioutil.ReadFile(gdrive.FileClientSecret)
	if err != nil {
		log.Fatalf("Unable to read client secret file: %v", err)
	}

	config, err := google.ConfigFromJSON(b, drive.DriveScope)
	if err != nil {
		log.Fatalf("Unable to parse client secret file to config: %v", err)
	}
	client := gdrive.GetClient(ctx, config)

	srv, err := drive.New(client)
	if err != nil {
		log.Fatalf("Unable to retrieve drive Client %v", err)
	}

	log.Printf("Checking files in account %s", account)

	err = check(srv, account)

	if err != nil {
		log.Fatal(err.Error())
	}

}