From f9ac0ab1091f3cd391c66279a3e644f4a54cb868 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 22 Jan 2013 09:52:01 -0800 Subject: [PATCH] pkg/client: stop using Superset for sharing Change-Id: I4f034b73584413d3d37f399680c67330783951b2 --- pkg/client/client.go | 13 +++++++------ pkg/schema/blob.go | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index 10217c81a..52c404a92 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -121,19 +121,20 @@ func NewFromShareRoot(shareBlobURL string) (c *Client, target *blobref.BlobRef, return nil, nil, fmt.Errorf("Error fetching %s: %v", shareBlobURL, err) } defer res.Body.Close() - ss, err := schema.ParseSuperset(res.Body) + blob, err := schema.BlobFromReader(blobref.Parse(root), res.Body) if err != nil { return nil, nil, fmt.Errorf("Error parsing JSON from %s: %v", shareBlobURL, err) } - if ss.AuthType != "haveref" { - return nil, nil, fmt.Errorf("Unknown share authType of %q", ss.AuthType) + if blob.ShareAuthType() != "haveref" { + return nil, nil, fmt.Errorf("Unknown share authType of %q", blob.ShareAuthType()) } - if ss.Target == nil { + target = blob.ShareTarget() + if target == nil { return nil, nil, fmt.Errorf("No target.") } - c.via[ss.Target.String()] = root + c.via[target.String()] = root // TODO(bradfitz): send via in requests, populate via as we fetch more things - return c, ss.Target, nil + return c, target, nil } // SetHTTPClient sets the Camlistore client's HTTP client. diff --git a/pkg/schema/blob.go b/pkg/schema/blob.go index 30392107f..0b5213cbd 100644 --- a/pkg/schema/blob.go +++ b/pkg/schema/blob.go @@ -124,6 +124,20 @@ func (b *Blob) StaticSetMembers() []*blobref.BlobRef { return s } +func (b *Blob) ShareAuthType() string { + if b.Type() != "share" { + return "" + } + return b.ss.AuthType +} + +func (b *Blob) ShareTarget() *blobref.BlobRef { + if b.Type() != "share" { + return nil + } + return b.ss.Target +} + // ModTime returns the "unixMtime" field, or the zero time. func (b *Blob) ModTime() time.Time { return b.ss.ModTime() }