From 8d1ea5ba0ce0b2be545e7f3e086800031f91c920 Mon Sep 17 00:00:00 2001 From: Gabor Tanz Date: Sat, 28 Apr 2018 23:48:36 +0200 Subject: [PATCH] fix handling of single file torrents --- cmd/magneticod/bittorrent/operations.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/magneticod/bittorrent/operations.go b/cmd/magneticod/bittorrent/operations.go index 33e96e4..d0e65df 100644 --- a/cmd/magneticod/bittorrent/operations.go +++ b/cmd/magneticod/bittorrent/operations.go @@ -361,6 +361,14 @@ func (ms *MetadataSink) awaitMetadata(infoHash metainfo.Hash, peer Peer) { } var files []persistence.File + // If there is only one file, there won't be a Files slice. That's why we need to add it here + if len(info.Files) == 0 { + files = append(files, persistence.File{ + Size: info.Length, + Path: info.Name, + }) + } + for _, file := range info.Files { if file.Length < 0 { zap.L().Debug(