From a7abc9cdcc1d8b9fae1b064ea5df8ed316aefa58 Mon Sep 17 00:00:00 2001 From: Mib Kd743naq Date: Fri, 2 Dec 2016 05:25:27 +0100 Subject: [PATCH 1/2] Fix bad formatting introduced by e855047ec License: MIT Signed-off-by: Mib Kd743naq --- blocks/blockstore/util/remove.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/blockstore/util/remove.go b/blocks/blockstore/util/remove.go index 3c16549bf53..e4ae678682e 100644 --- a/blocks/blockstore/util/remove.go +++ b/blocks/blockstore/util/remove.go @@ -29,7 +29,7 @@ type RmBlocksOpts struct { func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []*cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) { // make the channel large enough to hold any result to avoid - // blocking while holding the GCLock + // blocking while holding the GCLock out := make(chan interface{}, len(cids)) go func() { defer close(out) From 8ee4280f7b52e70b7ee3d7944f77c3425507ab62 Mon Sep 17 00:00:00 2001 From: Mib Kd743naq Date: Fri, 2 Dec 2016 06:37:11 +0100 Subject: [PATCH 2/2] 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 [1] https://developers.google.com/protocol-buffers/docs/proto#specifying-field-rules --- unixfs/pb/unixfs.pb.go | 10 +++++++--- unixfs/pb/unixfs.proto | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/unixfs/pb/unixfs.pb.go b/unixfs/pb/unixfs.pb.go index 55348ad7661..ffd3bb905f3 100644 --- a/unixfs/pb/unixfs.pb.go +++ b/unixfs/pb/unixfs.pb.go @@ -15,10 +15,12 @@ It has these top-level messages: package unixfs_pb import proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto" +import fmt "fmt" import math "math" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal +var _ = fmt.Errorf var _ = math.Inf type Data_DataType int32 @@ -64,8 +66,8 @@ func (x *Data_DataType) UnmarshalJSON(data []byte) error { } type Data struct { - Type *Data_DataType `protobuf:"varint,1,req,enum=unixfs.pb.Data_DataType" json:"Type,omitempty"` - Data []byte `protobuf:"bytes,2,opt" json:"Data,omitempty"` + Type *Data_DataType `protobuf:"varint,1,req,name=Type,enum=unixfs.pb.Data_DataType" json:"Type,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=Data" json:"Data,omitempty"` Filesize *uint64 `protobuf:"varint,3,opt,name=filesize" json:"filesize,omitempty"` Blocksizes []uint64 `protobuf:"varint,4,rep,name=blocksizes" json:"blocksizes,omitempty"` XXX_unrecognized []byte `json:"-"` @@ -104,7 +106,7 @@ func (m *Data) GetBlocksizes() []uint64 { } type Metadata struct { - MimeType *string `protobuf:"bytes,1,req" json:"MimeType,omitempty"` + MimeType *string `protobuf:"bytes,1,opt,name=MimeType" json:"MimeType,omitempty"` XXX_unrecognized []byte `json:"-"` } @@ -120,5 +122,7 @@ func (m *Metadata) GetMimeType() string { } func init() { + proto.RegisterType((*Data)(nil), "unixfs.pb.Data") + proto.RegisterType((*Metadata)(nil), "unixfs.pb.Metadata") proto.RegisterEnum("unixfs.pb.Data_DataType", Data_DataType_name, Data_DataType_value) } diff --git a/unixfs/pb/unixfs.proto b/unixfs/pb/unixfs.proto index 4a52c3af573..2e4d47947fb 100644 --- a/unixfs/pb/unixfs.proto +++ b/unixfs/pb/unixfs.proto @@ -16,5 +16,5 @@ message Data { } message Metadata { - required string MimeType = 1; + optional string MimeType = 1; }