diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 1177fe43..9df7e109 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -11758,35 +11758,11 @@ func (t *String_File) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 3 - if t.Gzip == nil { - fieldCount-- - } - - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + if _, err := cw.Write([]byte{162}); err != nil { return err } - // t.Gzip (tangled.String_File_Gzip) (struct) - if t.Gzip != nil { - - if len("gzip") > 1000000 { - return xerrors.Errorf("Value in field \"gzip\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("gzip"))); err != nil { - return err - } - if _, err := cw.WriteString(string("gzip")); err != nil { - return err - } - - if err := t.Gzip.MarshalCBOR(cw); err != nil { - return err - } - } - // t.Name (string) (string) if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") @@ -11869,27 +11845,7 @@ func (t *String_File) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Gzip (tangled.String_File_Gzip) (struct) - case "gzip": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.Gzip = new(String_File_Gzip) - if err := t.Gzip.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Gzip pointer: %w", err) - } - } - - } - // t.Name (string) (string) + // t.Name (string) (string) case "name": { @@ -11931,152 +11887,3 @@ func (t *String_File) UnmarshalCBOR(r io.Reader) (err error) { return nil } -func (t *String_File_Gzip) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - - cw := cbg.NewCborWriter(w) - - if _, err := cw.Write([]byte{162}); err != nil { - return err - } - - // t.RealMime (string) (string) - if len("realMime") > 1000000 { - return xerrors.Errorf("Value in field \"realMime\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("realMime"))); err != nil { - return err - } - if _, err := cw.WriteString(string("realMime")); err != nil { - return err - } - - if len(t.RealMime) > 1000000 { - return xerrors.Errorf("Value in field t.RealMime was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RealMime))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.RealMime)); err != nil { - return err - } - - // t.RealSize (int64) (int64) - if len("realSize") > 1000000 { - return xerrors.Errorf("Value in field \"realSize\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("realSize"))); err != nil { - return err - } - if _, err := cw.WriteString(string("realSize")); err != nil { - return err - } - - if t.RealSize >= 0 { - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.RealSize)); err != nil { - return err - } - } else { - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.RealSize-1)); err != nil { - return err - } - } - - return nil -} - -func (t *String_File_Gzip) UnmarshalCBOR(r io.Reader) (err error) { - *t = String_File_Gzip{} - - cr := cbg.NewCborReader(r) - - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - defer func() { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - }() - - if maj != cbg.MajMap { - return fmt.Errorf("cbor input should be of type map") - } - - if extra > cbg.MaxLength { - return fmt.Errorf("String_File_Gzip: map struct too large (%d)", extra) - } - - n := extra - - nameBuf := make([]byte, 8) - for i := uint64(0); i < n; i++ { - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) - if err != nil { - return err - } - - if !ok { - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { - return err - } - continue - } - - switch string(nameBuf[:nameLen]) { - // t.RealMime (string) (string) - case "realMime": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.RealMime = string(sval) - } - // t.RealSize (int64) (int64) - case "realSize": - { - maj, extra, err := cr.ReadHeader() - if err != nil { - return err - } - var extraI int64 - switch maj { - case cbg.MajUnsignedInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 positive overflow") - } - case cbg.MajNegativeInt: - extraI = int64(extra) - if extraI < 0 { - return fmt.Errorf("int64 negative overflow") - } - extraI = -1 - extraI - default: - return fmt.Errorf("wrong type for int64 field: %d", maj) - } - - t.RealSize = int64(extraI) - } - - default: - // Field doesn't exist on this type, so ignore it - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { - return err - } - } - } - - return nil -} diff --git a/api/tangled/tangledstring.go b/api/tangled/tangledstring.go index 1d4224da..efacfd94 100644 --- a/api/tangled/tangledstring.go +++ b/api/tangled/tangledstring.go @@ -32,14 +32,6 @@ type String struct { type String_File struct { // content: file content Content *util.LexBlob `json:"content" cborgen:"content"` - // gzip: underlying blob metadata. provided when we are using gzip hack for text/* mimetype - Gzip *String_File_Gzip `json:"gzip,omitempty" cborgen:"gzip,omitempty"` // name: filename including extension Name string `json:"name" cborgen:"name"` } - -// underlying blob metadata. provided when we are using gzip hack for text/* mimetype -type String_File_Gzip struct { - RealMime string `json:"realMime" cborgen:"realMime"` - RealSize int64 `json:"realSize" cborgen:"realSize"` -} diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go index 01963daa..35f1b686 100644 --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -62,7 +62,6 @@ func main() { tangled.SpindleMember{}, tangled.String{}, tangled.String_File{}, - tangled.String_File_Gzip{}, ); err != nil { panic(err) } diff --git a/lexicons/string/string.json b/lexicons/string/string.json index e0eda03b..31790fdd 100644 --- a/lexicons/string/string.json +++ b/lexicons/string/string.json @@ -66,18 +66,9 @@ }, "content": { "type": "blob", - "accept": ["text/plain", "application/gzip"], + "accept": ["text/plain"], "maxSize": 8388608, "description": "file content" - }, - "gzip": { - "type": "object", - "required": ["realSize", "realMime"], - "properties": { - "realSize": { "type": "integer" }, - "realMime": { "type": "string" } - }, - "description": "underlying blob metadata. provided when we are using gzip hack for text/* mimetype" } } }