We can't trust anyone when splitting paths. Path separator may be / and may be \

This commit is contained in:
rumanzo 2021-05-07 15:39:47 +03:00
parent 96ed446c41
commit f421df467c

View File

@ -253,7 +253,12 @@ func (newstructure *NewTorrentStructure) FillSavePaths() {
torrentname = newstructure.TorrentFile["info"].(map[string]interface{})["name"].(string) torrentname = newstructure.TorrentFile["info"].(map[string]interface{})["name"].(string)
} }
origpath := newstructure.Path 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] lastdirname := dirpaths[len(dirpaths)-1]
if newstructure.HasFiles { if newstructure.HasFiles {
if lastdirname == torrentname { if lastdirname == torrentname {