diff --git a/pkg/schema/blob.go b/pkg/schema/blob.go index eb6a6c4bf..be38c9519 100644 --- a/pkg/schema/blob.go +++ b/pkg/schema/blob.go @@ -91,10 +91,10 @@ func (b *Blob) FileName() string { func (b *Blob) ClaimDate() (time.Time, error) { var ct time.Time claimDate := b.ss.ClaimDate - if claimDate == "" { + if claimDate.IsZero() { return ct, MissingFieldError("claimDate") } - return time.Parse(time.RFC3339, claimDate) + return claimDate.Time(), nil } // ByteParts returns the "parts" field. The caller owns the returned @@ -120,7 +120,7 @@ func (b *Blob) Builder() *Builder { // AsClaim returns a Claim if the receiver Blob has all the required fields. func (b *Blob) AsClaim() (c Claim, ok bool) { - if blobref.Parse(b.ss.Signer) != nil && b.ss.Sig != "" && b.ss.ClaimType != "" && b.ss.ClaimDate != "" { + if b.ss.Signer != nil && b.ss.Sig != "" && b.ss.ClaimType != "" && !b.ss.ClaimDate.IsZero() { return Claim{b}, true } return @@ -132,7 +132,7 @@ func (b *Blob) DirectoryEntries() *blobref.BlobRef { if b.Type() != "directory" { return nil } - return blobref.Parse(b.ss.Entries) + return b.ss.Entries } func (b *Blob) StaticSetMembers() []*blobref.BlobRef { @@ -140,8 +140,8 @@ func (b *Blob) StaticSetMembers() []*blobref.BlobRef { return nil } s := make([]*blobref.BlobRef, 0, len(b.ss.Members)) - for _, refstr := range b.ss.Members { - if ref := blobref.Parse(refstr); ref != nil { + for _, ref := range b.ss.Members { + if ref != nil { s = append(s, ref) } } @@ -174,7 +174,7 @@ type Claim struct { func (c Claim) Blob() *Blob { return c.b } // ClaimDate returns the blob's "claimDate" field. -func (c Claim) ClaimDateString() string { return c.b.ss.ClaimDate } +func (c Claim) ClaimDateString() string { return c.b.ss.ClaimDate.String() } // ClaimType returns the blob's "claimType" field. func (c Claim) ClaimType() string { return c.b.ss.ClaimType } @@ -188,7 +188,7 @@ func (c Claim) Value() string { return c.b.ss.Value } // ModifiedPermanode returns the claim's "permaNode" field, if it's // a claim that modifies a permanode. Otherwise nil is returned. func (c Claim) ModifiedPermanode() *blobref.BlobRef { - return blobref.Parse(c.b.ss.Permanode) + return c.b.ss.Permanode } // A Builder builds a JSON blob. diff --git a/pkg/schema/dirreader.go b/pkg/schema/dirreader.go index b3b64b13d..d8addf4eb 100644 --- a/pkg/schema/dirreader.go +++ b/pkg/schema/dirreader.go @@ -86,7 +86,7 @@ func (dr *DirReader) StaticSet() ([]*blobref.BlobRef, error) { if dr.staticSet != nil { return dr.staticSet, nil } - staticSetBlobref := blobref.Parse(dr.ss.Entries) + staticSetBlobref := dr.ss.Entries if staticSetBlobref == nil { return nil, fmt.Errorf("schema/filereader: Invalid blobref\n") } @@ -101,8 +101,7 @@ func (dr *DirReader) StaticSet() ([]*blobref.BlobRef, error) { if ss.Type != "static-set" { return nil, fmt.Errorf("schema/filereader: expected \"static-set\" schema blob for %s, got %q", staticSetBlobref, ss.Type) } - for _, s := range ss.Members { - member := blobref.Parse(s) + for _, member := range ss.Members { if member == nil { return nil, fmt.Errorf("schema/filereader: invalid (static-set member) blobref\n") } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index f1b994b3d..e403e7bc8 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -39,6 +39,7 @@ import ( "time" "camlistore.org/pkg/blobref" + "camlistore.org/pkg/types" "camlistore.org/third_party/github.com/camlistore/goexif/exif" ) @@ -202,15 +203,15 @@ type superset struct { Version int `json:"camliVersion"` Type string `json:"camliType"` - Signer string `json:"camliSigner"` - Sig string `json:"camliSig"` + Signer *blobref.BlobRef `json:"camliSigner"` + Sig string `json:"camliSig"` - ClaimType string `json:"claimType"` - ClaimDate string `json:"claimDate"` + ClaimType string `json:"claimType"` + ClaimDate types.Time3339 `json:"claimDate"` - Permanode string `json:"permaNode"` - Attribute string `json:"attribute"` - Value string `json:"value"` + Permanode *blobref.BlobRef `json:"permaNode"` + Attribute string `json:"attribute"` + Value string `json:"value"` // FileName and FileNameBytes represent one of the two // representations of file names in schema blobs. They should @@ -235,8 +236,8 @@ type superset struct { // See doc/schema/bytes.txt and doc/schema/files/file.txt. Parts []*BytesPart `json:"parts"` - Entries string `json:"entries"` // for directories, a blobref to a static-set - Members []string `json:"members"` // for static sets (for directory static-sets: blobrefs to child dirs/files) + Entries *blobref.BlobRef `json:"entries"` // for directories, a blobref to a static-set + Members []*blobref.BlobRef `json:"members"` // for static sets (for directory static-sets: blobrefs to child dirs/files) // Target is a "share" blob's target (the thing being shared) Target *blobref.BlobRef `json:"target"`