diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index 4505d3f..563c2c6 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -84,7 +84,7 @@ func (t *TorrentManager) repairAll() { if toRepair.Cardinality() == 0 { t.log.Info("Periodic repair found no broken torrents to repair") } else { - t.log.Debugf("Periodic repair found %d broken torrents to repair in total", toRepair.Cardinality()) + t.log.Info("Periodic repair found %d broken torrents to repair in total", toRepair.Cardinality()) toRepair.Each(func(torrent *Torrent) bool { t.Repair(torrent) diff --git a/internal/universal/check.go b/internal/universal/check.go index 5580c04..f4484de 100644 --- a/internal/universal/check.go +++ b/internal/universal/check.go @@ -73,7 +73,8 @@ func CheckVersionFile(w http.ResponseWriter, req *http.Request, torMgr *torrent. } func getContentMimeType(filePath string) string { - switch filepath.Ext(filePath) { + fileExt := strings.ToLower(filepath.Ext(filePath)) + switch fileExt { case ".mkv": return "video/x-matroska" case ".mp4": diff --git a/internal/universal/downloader.go b/internal/universal/downloader.go index 7aa15bc..dd3c491 100644 --- a/internal/universal/downloader.go +++ b/internal/universal/downloader.go @@ -64,18 +64,15 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp http.Error(resp, "File is not available", http.StatusNotFound) return } else { - unrestrictFilename := strings.TrimPrefix(unrestrict.Filename, "/") - if !strings.Contains(fileName, unrestrictFilename) { + if unrestrict.Filesize != file.Bytes { // this is possible if there's only 1 streamable file in the torrent // and then suddenly it's a rar file - actualExt := filepath.Ext(unrestrictFilename) - expectedExt := filepath.Ext(fileName) + actualExt := strings.ToLower(filepath.Ext(unrestrict.Filename)) + expectedExt := strings.ToLower(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) - http.Error(resp, "File is not available", http.StatusNotFound) - return } else { - log.Warnf("Filename mismatch: %s and %s", fileName, unrestrict.Filename) + log.Warnf("File mismatch: %s and %s", fileName, unrestrict.Filename) } } if cfg.ShouldServeFromRclone() { @@ -109,15 +106,15 @@ func (dl *Downloader) DownloadLink(fileName, link string, resp http.ResponseWrit http.Error(resp, "File is not available", http.StatusNotFound) return } else { - if unrestrict.Filename != fileName { + lFilename := strings.ToLower(fileName) + unrestrictFilename := strings.ToLower(strings.TrimPrefix(unrestrict.Filename, "/")) + if strings.Contains(lFilename, 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) - expectedExt := filepath.Ext(fileName) + actualExt := filepath.Ext(unrestrictFilename) + expectedExt := filepath.Ext(lFilename) 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) - http.Error(resp, "File is not available", http.StatusNotFound) - return } else { log.Warnf("Filename mismatch: %s and %s", fileName, unrestrict.Filename) }