From: Matt Joiner Date: Thu, 26 Feb 2015 11:12:02 +0000 (+1100) Subject: Fixes for single/multi-file torrent Infos X-Git-Tag: v1.0.0~1199^2~3 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a5d60fd76fa2edc3db621673b70ad5845347e5f8;p=btrtrc.git Fixes for single/multi-file torrent Infos --- diff --git a/metainfo/metainfo.go b/metainfo/metainfo.go index 919ee6af..0b605645 100644 --- a/metainfo/metainfo.go +++ b/metainfo/metainfo.go @@ -46,6 +46,10 @@ type Info struct { Files []FileInfo `bencode:"files,omitempty"` } +func (i *Info) IsDir() bool { + return len(i.Files) != 0 +} + // The files field, converted up from the old single-file in the parent info // dict if necessary. This is a helper to avoid having to conditionally handle // single and multi-file torrent infos. @@ -53,7 +57,9 @@ func (i *Info) UpvertedFiles() []FileInfo { if len(i.Files) == 0 { return []FileInfo{{ Length: i.Length, - Path: []string{i.Name}, + // Callers should determine that Info.Name is the basename, and + // thus a regular file. + Path: nil, }} } return i.Files