pkg/client: stop using Superset for sharing

Change-Id: I4f034b73584413d3d37f399680c67330783951b2
This commit is contained in:
Brad Fitzpatrick 2013-01-22 09:52:01 -08:00
parent bac9664784
commit f9ac0ab109
2 changed files with 21 additions and 6 deletions

View File

@ -121,19 +121,20 @@ func NewFromShareRoot(shareBlobURL string) (c *Client, target *blobref.BlobRef,
return nil, nil, fmt.Errorf("Error fetching %s: %v", shareBlobURL, err) return nil, nil, fmt.Errorf("Error fetching %s: %v", shareBlobURL, err)
} }
defer res.Body.Close() defer res.Body.Close()
ss, err := schema.ParseSuperset(res.Body) blob, err := schema.BlobFromReader(blobref.Parse(root), res.Body)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Error parsing JSON from %s: %v", shareBlobURL, err) return nil, nil, fmt.Errorf("Error parsing JSON from %s: %v", shareBlobURL, err)
} }
if ss.AuthType != "haveref" { if blob.ShareAuthType() != "haveref" {
return nil, nil, fmt.Errorf("Unknown share authType of %q", ss.AuthType) 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.") 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 // 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. // SetHTTPClient sets the Camlistore client's HTTP client.

View File

@ -124,6 +124,20 @@ func (b *Blob) StaticSetMembers() []*blobref.BlobRef {
return s 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. // ModTime returns the "unixMtime" field, or the zero time.
func (b *Blob) ModTime() time.Time { return b.ss.ModTime() } func (b *Blob) ModTime() time.Time { return b.ss.ModTime() }