From f421df467c6a84e2c37395c3f402066372072391 Mon Sep 17 00:00:00 2001 From: rumanzo Date: Fri, 7 May 2021 15:39:47 +0300 Subject: [PATCH] We can't trust anyone when splitting paths. Path separator may be / and may be \ --- libtorrent/torrent.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libtorrent/torrent.go b/libtorrent/torrent.go index 2435cdc..2ceb102 100644 --- a/libtorrent/torrent.go +++ b/libtorrent/torrent.go @@ -253,7 +253,12 @@ func (newstructure *NewTorrentStructure) FillSavePaths() { torrentname = newstructure.TorrentFile["info"].(map[string]interface{})["name"].(string) } origpath := newstructure.Path - dirpaths := strings.Split(origpath, "\\") + var dirpaths []string + if contains := strings.Contains(origpath, "\\"); contains { + dirpaths = strings.Split(origpath, "\\") + } else { + dirpaths = strings.Split(origpath, "/") + } lastdirname := dirpaths[len(dirpaths)-1] if newstructure.HasFiles { if lastdirname == torrentname {