Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

lexicons/string: remove gzip hack

Signed-off-by: Seongmin Lee <git@boltless.me>

author
Seongmin Lee
date (Jun 17, 2026, 12:31 AM +0900) commit 71588c93 parent 75d89e7f change-id otptmsxo
+3 -214
+2 -195
api/tangled/cbor_gen.go
··· 11758 11758 } 11759 11759 11760 11760 cw := cbg.NewCborWriter(w) 11761 - fieldCount := 3 11762 11761 11763 - if t.Gzip == nil { 11764 - fieldCount-- 11765 - } 11766 - 11767 - if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 11762 + if _, err := cw.Write([]byte{162}); err != nil { 11768 11763 return err 11769 - } 11770 - 11771 - // t.Gzip (tangled.String_File_Gzip) (struct) 11772 - if t.Gzip != nil { 11773 - 11774 - if len("gzip") > 1000000 { 11775 - return xerrors.Errorf("Value in field \"gzip\" was too long") 11776 - } 11777 - 11778 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("gzip"))); err != nil { 11779 - return err 11780 - } 11781 - if _, err := cw.WriteString(string("gzip")); err != nil { 11782 - return err 11783 - } 11784 - 11785 - if err := t.Gzip.MarshalCBOR(cw); err != nil { 11786 - return err 11787 - } 11788 11764 } 11789 11765 11790 11766 // t.Name (string) (string) ··· 11869 11845 } 11870 11846 11871 11847 switch string(nameBuf[:nameLen]) { 11872 - // t.Gzip (tangled.String_File_Gzip) (struct) 11873 - case "gzip": 11874 - 11875 - { 11876 - 11877 - b, err := cr.ReadByte() 11878 - if err != nil { 11879 - return err 11880 - } 11881 - if b != cbg.CborNull[0] { 11882 - if err := cr.UnreadByte(); err != nil { 11883 - return err 11884 - } 11885 - t.Gzip = new(String_File_Gzip) 11886 - if err := t.Gzip.UnmarshalCBOR(cr); err != nil { 11887 - return xerrors.Errorf("unmarshaling t.Gzip pointer: %w", err) 11888 - } 11889 - } 11890 - 11891 - } 11892 - // t.Name (string) (string) 11848 + // t.Name (string) (string) 11893 11849 case "name": 11894 11850 11895 11851 { ··· 11931 11887 11932 11888 return nil 11933 11889 } 11934 - func (t *String_File_Gzip) MarshalCBOR(w io.Writer) error { 11935 - if t == nil { 11936 - _, err := w.Write(cbg.CborNull) 11937 - return err 11938 - } 11939 - 11940 - cw := cbg.NewCborWriter(w) 11941 - 11942 - if _, err := cw.Write([]byte{162}); err != nil { 11943 - return err 11944 - } 11945 - 11946 - // t.RealMime (string) (string) 11947 - if len("realMime") > 1000000 { 11948 - return xerrors.Errorf("Value in field \"realMime\" was too long") 11949 - } 11950 - 11951 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("realMime"))); err != nil { 11952 - return err 11953 - } 11954 - if _, err := cw.WriteString(string("realMime")); err != nil { 11955 - return err 11956 - } 11957 - 11958 - if len(t.RealMime) > 1000000 { 11959 - return xerrors.Errorf("Value in field t.RealMime was too long") 11960 - } 11961 - 11962 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RealMime))); err != nil { 11963 - return err 11964 - } 11965 - if _, err := cw.WriteString(string(t.RealMime)); err != nil { 11966 - return err 11967 - } 11968 - 11969 - // t.RealSize (int64) (int64) 11970 - if len("realSize") > 1000000 { 11971 - return xerrors.Errorf("Value in field \"realSize\" was too long") 11972 - } 11973 - 11974 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("realSize"))); err != nil { 11975 - return err 11976 - } 11977 - if _, err := cw.WriteString(string("realSize")); err != nil { 11978 - return err 11979 - } 11980 - 11981 - if t.RealSize >= 0 { 11982 - if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.RealSize)); err != nil { 11983 - return err 11984 - } 11985 - } else { 11986 - if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.RealSize-1)); err != nil { 11987 - return err 11988 - } 11989 - } 11990 - 11991 - return nil 11992 - } 11993 - 11994 - func (t *String_File_Gzip) UnmarshalCBOR(r io.Reader) (err error) { 11995 - *t = String_File_Gzip{} 11996 - 11997 - cr := cbg.NewCborReader(r) 11998 - 11999 - maj, extra, err := cr.ReadHeader() 12000 - if err != nil { 12001 - return err 12002 - } 12003 - defer func() { 12004 - if err == io.EOF { 12005 - err = io.ErrUnexpectedEOF 12006 - } 12007 - }() 12008 - 12009 - if maj != cbg.MajMap { 12010 - return fmt.Errorf("cbor input should be of type map") 12011 - } 12012 - 12013 - if extra > cbg.MaxLength { 12014 - return fmt.Errorf("String_File_Gzip: map struct too large (%d)", extra) 12015 - } 12016 - 12017 - n := extra 12018 - 12019 - nameBuf := make([]byte, 8) 12020 - for i := uint64(0); i < n; i++ { 12021 - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 12022 - if err != nil { 12023 - return err 12024 - } 12025 - 12026 - if !ok { 12027 - // Field doesn't exist on this type, so ignore it 12028 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 12029 - return err 12030 - } 12031 - continue 12032 - } 12033 - 12034 - switch string(nameBuf[:nameLen]) { 12035 - // t.RealMime (string) (string) 12036 - case "realMime": 12037 - 12038 - { 12039 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 12040 - if err != nil { 12041 - return err 12042 - } 12043 - 12044 - t.RealMime = string(sval) 12045 - } 12046 - // t.RealSize (int64) (int64) 12047 - case "realSize": 12048 - { 12049 - maj, extra, err := cr.ReadHeader() 12050 - if err != nil { 12051 - return err 12052 - } 12053 - var extraI int64 12054 - switch maj { 12055 - case cbg.MajUnsignedInt: 12056 - extraI = int64(extra) 12057 - if extraI < 0 { 12058 - return fmt.Errorf("int64 positive overflow") 12059 - } 12060 - case cbg.MajNegativeInt: 12061 - extraI = int64(extra) 12062 - if extraI < 0 { 12063 - return fmt.Errorf("int64 negative overflow") 12064 - } 12065 - extraI = -1 - extraI 12066 - default: 12067 - return fmt.Errorf("wrong type for int64 field: %d", maj) 12068 - } 12069 - 12070 - t.RealSize = int64(extraI) 12071 - } 12072 - 12073 - default: 12074 - // Field doesn't exist on this type, so ignore it 12075 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 12076 - return err 12077 - } 12078 - } 12079 - } 12080 - 12081 - return nil 12082 - }
-8
api/tangled/tangledstring.go
··· 32 32 type String_File struct { 33 33 // content: file content 34 34 Content *util.LexBlob `json:"content" cborgen:"content"` 35 - // gzip: underlying blob metadata. provided when we are using gzip hack for text/* mimetype 36 - Gzip *String_File_Gzip `json:"gzip,omitempty" cborgen:"gzip,omitempty"` 37 35 // name: filename including extension 38 36 Name string `json:"name" cborgen:"name"` 39 37 } 40 - 41 - // underlying blob metadata. provided when we are using gzip hack for text/* mimetype 42 - type String_File_Gzip struct { 43 - RealMime string `json:"realMime" cborgen:"realMime"` 44 - RealSize int64 `json:"realSize" cborgen:"realSize"` 45 - }
-1
cmd/cborgen/cborgen.go
··· 62 62 tangled.SpindleMember{}, 63 63 tangled.String{}, 64 64 tangled.String_File{}, 65 - tangled.String_File_Gzip{}, 66 65 ); err != nil { 67 66 panic(err) 68 67 }
+1 -10
lexicons/string/string.json
··· 66 66 }, 67 67 "content": { 68 68 "type": "blob", 69 - "accept": ["text/plain", "application/gzip"], 69 + "accept": ["text/plain"], 70 70 "maxSize": 8388608, 71 71 "description": "file content" 72 - }, 73 - "gzip": { 74 - "type": "object", 75 - "required": ["realSize", "realMime"], 76 - "properties": { 77 - "realSize": { "type": "integer" }, 78 - "realMime": { "type": "string" } 79 - }, 80 - "description": "underlying blob metadata. provided when we are using gzip hack for text/* mimetype" 81 72 } 82 73 } 83 74 }