Switch unixfs.Metadata.MimeType to optional
*** THIS IS A BREAKING CHANGE *** as per [1]: "Required is forever" Nevertheless this seems like a good idea at this time: there are no known producers ( nor consumers ) of MetaData nodes, and the current requirement of MimeType has an extremely narrow application scope. This change could very well be rejected in lieu of implementing a new type of node ( e.g. TheRealMetadata ) in the DataType enum. Based on https://github.com/ipfs/go-ipfs/issues/3451#issuecomment-264246718 License: MIT Signed-off-by: Mib Kd743naq <mib.kd743naq@gmail.com> [1] https://developers.google.com/protocol-buffers/docs/proto#specifying-field-rules
Mib Kd743naq committed
Dec 2, 2016 at 06:37 UTC
8ee4280f7b52e70b7ee3d7944f77c3425507ab62
2 files changed
+8
-4
unixfs/pb/unixfs.pb.go
+7
-3
@@ -15,10 +15,12 @@ It has these top-level messages:
15
package unixfs_pb
16
17
import proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
18
+import fmt "fmt"
19
import math "math"
20
21
// Reference imports to suppress errors if they are not otherwise used.
22
var _ = proto.Marshal
23
+var _ = fmt.Errorf
24
var _ = math.Inf
25
26
type Data_DataType int32
@@ -64,8 +66,8 @@ func (x *Data_DataType) UnmarshalJSON(data []byte) error {
66
}
67
68
type Data struct {
67
- Type *Data_DataType `protobuf:"varint,1,req,enum=unixfs.pb.Data_DataType" json:"Type,omitempty"`
68
- Data []byte `protobuf:"bytes,2,opt" json:"Data,omitempty"`
69
+ Type *Data_DataType `protobuf:"varint,1,req,name=Type,enum=unixfs.pb.Data_DataType" json:"Type,omitempty"`
70
+ Data []byte `protobuf:"bytes,2,opt,name=Data" json:"Data,omitempty"`
71
Filesize *uint64 `protobuf:"varint,3,opt,name=filesize" json:"filesize,omitempty"`
72
Blocksizes []uint64 `protobuf:"varint,4,rep,name=blocksizes" json:"blocksizes,omitempty"`
73
XXX_unrecognized []byte `json:"-"`
@@ -104,7 +106,7 @@ func (m *Data) GetBlocksizes() []uint64 {
106
}
107
108
type Metadata struct {
107
- MimeType *string `protobuf:"bytes,1,req" json:"MimeType,omitempty"`
109
+ MimeType *string `protobuf:"bytes,1,opt,name=MimeType" json:"MimeType,omitempty"`
110
XXX_unrecognized []byte `json:"-"`
111
}
112
@@ -120,5 +122,7 @@ func (m *Metadata) GetMimeType() string {
122
}
123
124
func init() {
125
+ proto.RegisterType((*Data)(nil), "unixfs.pb.Data")
126
+ proto.RegisterType((*Metadata)(nil), "unixfs.pb.Metadata")
127
proto.RegisterEnum("unixfs.pb.Data_DataType", Data_DataType_name, Data_DataType_value)
128
}
unixfs/pb/unixfs.proto
+1
-1
@@ -16,5 +16,5 @@ message Data {
16
}
17
18
message Metadata {
19
- required string MimeType = 1;
19
+ optional string MimeType = 1;
20
}