本文整理汇总了Golang中camlistore/org/pkg/client.Client.UpdateShareChain方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.UpdateShareChain方法的具体用法?Golang Client.UpdateShareChain怎么用?Golang Client.UpdateShareChain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camlistore/org/pkg/client.Client
的用法示例。
在下文中一共展示了Client.UpdateShareChain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
client.AddFlags()
flag.Parse()
if *cmdmain.FlagHelp {
flag.PrintDefaults()
}
if *flagVersion {
fmt.Fprintf(os.Stderr, "camget version: %s\n", buildinfo.Version())
return
}
if *cmdmain.FlagLegal {
cmdmain.PrintLicenses()
return
}
if *flagGraph && flag.NArg() != 1 {
log.Fatalf("The --graph option requires exactly one parameter.")
}
var cl *client.Client
var items []blob.Ref
optTransportConfig := client.OptionTransportConfig(&client.TransportConfig{
Verbose: *flagHTTP,
})
if *flagShared != "" {
if client.ExplicitServer() != "" {
log.Fatal("Can't use --shared with an explicit blobserver; blobserver is implicit from the --shared URL.")
}
if flag.NArg() != 0 {
log.Fatal("No arguments permitted when using --shared")
}
cl1, target, err := client.NewFromShareRoot(*flagShared,
client.OptionInsecure(*flagInsecureTLS),
client.OptionTrustedCert(*flagTrustedCert),
optTransportConfig,
)
if err != nil {
log.Fatal(err)
}
cl = cl1
items = append(items, target)
} else {
if *flagTrustedCert != "" {
log.Fatal("Can't use --cert without --shared.")
}
cl = client.NewOrFail(client.OptionInsecure(*flagInsecureTLS), optTransportConfig)
for n := 0; n < flag.NArg(); n++ {
arg := flag.Arg(n)
br, ok := blob.Parse(arg)
if !ok {
log.Fatalf("Failed to parse argument %q as a blobref.", arg)
}
items = append(items, br)
}
}
httpStats := cl.HTTPStats()
diskCacheFetcher, err := cacher.NewDiskCache(cl)
if err != nil {
log.Fatalf("Error setting up local disk cache: %v", err)
}
defer diskCacheFetcher.Clean()
if *flagVerbose {
log.Printf("Using temp blob cache directory %s", diskCacheFetcher.Root)
}
if *flagShared != "" {
diskCacheFetcher.SetCacheHitHook(func(br blob.Ref, rc io.ReadCloser) (io.ReadCloser, error) {
var buf bytes.Buffer
if err := cl.UpdateShareChain(br, io.TeeReader(rc, &buf)); err != nil {
rc.Close()
return nil, err
}
return struct {
io.Reader
io.Closer
}{io.MultiReader(&buf, rc), rc}, nil
})
}
for _, br := range items {
if *flagGraph {
printGraph(diskCacheFetcher, br)
return
}
if *flagCheck {
// TODO: do HEAD requests checking if the blobs exists.
log.Fatal("not implemented")
return
}
if *flagOutput == "-" {
var rc io.ReadCloser
var err error
if *flagContents {
rc, err = schema.NewFileReader(diskCacheFetcher, br)
//.........这里部分代码省略.........