metainfo/bep47.go | 8 ++++++++ metainfo/fileinfo.go | 8 ++++++-- metainfo/info.go | 5 +++-- diff --git a/metainfo/bep47.go b/metainfo/bep47.go new file mode 100644 index 0000000000000000000000000000000000000000..884d88d65a4d68bce5484224ca41403afc509028 --- /dev/null +++ b/metainfo/bep47.go @@ -0,0 +1,8 @@ +package metainfo + +// See BEP 47. This is common to both Info and FileInfo. +type ExtendedFileAttrs struct { + Attr string `bencode:"attr,omitempty"` + SymlinkPath []string `bencode:"symlink path,omitempty"` + Sha1 string `bencode:"sha1,omitempty"` +} diff --git a/metainfo/fileinfo.go b/metainfo/fileinfo.go index 2a5ea01d1f88d476d80a9622b4fb6d601243bbd9..894018c10815a32a74be61291a48d05fea0c07e7 100644 --- a/metainfo/fileinfo.go +++ b/metainfo/fileinfo.go @@ -4,9 +4,13 @@ import "strings" // Information specific to a single file inside the MetaInfo structure. type FileInfo struct { - Length int64 `bencode:"length"` // BEP3 - Path []string `bencode:"path"` // BEP3 + // BEP3. With BEP 47 this can be optional, but we have no way to describe that without breaking + // the API. + Length int64 `bencode:"length"` + Path []string `bencode:"path"` // BEP3 PathUtf8 []string `bencode:"path.utf-8,omitempty"` + + ExtendedFileAttrs } func (fi *FileInfo) DisplayPath(info *Info) string { diff --git a/metainfo/info.go b/metainfo/info.go index 5eedfa3b4c41730ddb92543abfb855ad635e27e4..b5e4d6e179595574c143778469d245b2b2438805 100644 --- a/metainfo/info.go +++ b/metainfo/info.go @@ -17,8 +17,9 @@ PieceLength int64 `bencode:"piece length"` // BEP3 Pieces []byte `bencode:"pieces"` // BEP3 Name string `bencode:"name"` // BEP3 NameUtf8 string `bencode:"name.utf-8,omitempty"` - Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files - Private *bool `bencode:"private,omitempty"` // BEP27 + Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files + ExtendedFileAttrs + Private *bool `bencode:"private,omitempty"` // BEP27 // TODO: Document this field. Source string `bencode:"source,omitempty"` Files []FileInfo `bencode:"files,omitempty"` // BEP3, mutually exclusive with Length