Fix filename mismatch

This commit is contained in:
Ben Sarmiento
2024-01-27 01:25:23 +01:00
parent 1c0ae6e27f
commit 803240b2eb

View File

@@ -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)