Ejemplo n.º 1
0
func testDBTransactionIOWithRootKey(rootKeyStr string) *datastore.DBTransactionLogIO {
	homedir := os.Getenv("HOME")
	projectName := util.StringFromFileOrDie(path.Join(homedir, ".otaru", "projectname.txt"), "projectName")
	bs, err := datastore.NewDBTransactionLogIO(projectName, rootKeyStr, tu.TestCipher(), testClientSource())
	if err != nil {
		log.Fatalf("Failed to create DBTransactionLogIO: %v", err)
	}
	return bs
}
Ejemplo n.º 2
0
func testGCSBlobStore() *gcs.GCSBlobStore {
	homedir := os.Getenv("HOME")
	projectName := util.StringFromFileOrDie(path.Join(homedir, ".otaru", "projectname.txt"), "projectName")
	bs, err := gcs.NewGCSBlobStore(
		projectName,
		"otaru-test",
		testClientSource(),
		flags.O_RDWR,
	)
	if err != nil {
		log.Fatalf("Failed to create GCSBlobStore: %v", err)
	}
	return bs
}
Ejemplo n.º 3
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)

	flag.Usage = Usage
	flag.Parse()

	if flag.NArg() != 1 {
		Usage()
		os.Exit(2)
	}
	filepath := flag.Arg(0)

	f, err := os.Open(filepath)
	if err != nil {
		log.Printf("Failed to read file: %s", filepath)
	}
	defer f.Close()

	password := util.StringFromFileOrDie(*flagPasswordFile, "password")
	key := btncrypt.KeyFromPassword(password)
	c, err := btncrypt.NewCipher(key)
	if err != nil {
		log.Printf("Failed to init Cipher: %v", err)
		return
	}

	cr, err := chunkstore.NewChunkReader(f, c)
	if err != nil {
		log.Printf("Failed to init ChunkReader: %v", err)
		return
	}

	if *flagHeader {
		log.Printf("Header: %+v", cr.Header())
	}
	io.Copy(os.Stdout, cr)
}