From 803240b2ebbcb4c21d940c7df50e07b82723c9bc Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sat, 27 Jan 2024 01:25:23 +0100 Subject: [PATCH] Fix filename mismatch --- internal/universal/downloader.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/universal/downloader.go b/internal/universal/downloader.go index 56acd47..7aa15bc 100644 --- a/internal/universal/downloader.go +++ b/internal/universal/downloader.go @@ -64,10 +64,11 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp http.Error(resp, "File is not available", http.StatusNotFound) return } else { - if unrestrict.Filename != fileName { + unrestrictFilename := strings.TrimPrefix(unrestrict.Filename, "/") + if !strings.Contains(fileName, unrestrictFilename) { // this is possible if there's only 1 streamable file in the torrent // and then suddenly it's a rar file - actualExt := filepath.Ext(unrestrict.Filename) + actualExt := filepath.Ext(unrestrictFilename) expectedExt := filepath.Ext(fileName) if actualExt != expectedExt && unrestrict.Streamable != 1 { log.Warnf("File was changed and is not streamable: %s and %s (link=%s)", fileName, unrestrict.Filename, unrestrict.Link)