Consider file case when doing filename comparisons
This commit is contained in:
@@ -84,7 +84,7 @@ func (t *TorrentManager) repairAll() {
|
|||||||
if toRepair.Cardinality() == 0 {
|
if toRepair.Cardinality() == 0 {
|
||||||
t.log.Info("Periodic repair found no broken torrents to repair")
|
t.log.Info("Periodic repair found no broken torrents to repair")
|
||||||
} else {
|
} 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 {
|
toRepair.Each(func(torrent *Torrent) bool {
|
||||||
t.Repair(torrent)
|
t.Repair(torrent)
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ func CheckVersionFile(w http.ResponseWriter, req *http.Request, torMgr *torrent.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getContentMimeType(filePath string) string {
|
func getContentMimeType(filePath string) string {
|
||||||
switch filepath.Ext(filePath) {
|
fileExt := strings.ToLower(filepath.Ext(filePath))
|
||||||
|
switch fileExt {
|
||||||
case ".mkv":
|
case ".mkv":
|
||||||
return "video/x-matroska"
|
return "video/x-matroska"
|
||||||
case ".mp4":
|
case ".mp4":
|
||||||
|
|||||||
@@ -64,18 +64,15 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
|
|||||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
unrestrictFilename := strings.TrimPrefix(unrestrict.Filename, "/")
|
if unrestrict.Filesize != file.Bytes {
|
||||||
if !strings.Contains(fileName, unrestrictFilename) {
|
|
||||||
// this is possible if there's only 1 streamable file in the torrent
|
// this is possible if there's only 1 streamable file in the torrent
|
||||||
// and then suddenly it's a rar file
|
// and then suddenly it's a rar file
|
||||||
actualExt := filepath.Ext(unrestrictFilename)
|
actualExt := strings.ToLower(filepath.Ext(unrestrict.Filename))
|
||||||
expectedExt := filepath.Ext(fileName)
|
expectedExt := strings.ToLower(filepath.Ext(fileName))
|
||||||
if actualExt != expectedExt && unrestrict.Streamable != 1 {
|
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)
|
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 {
|
} else {
|
||||||
log.Warnf("Filename mismatch: %s and %s", fileName, unrestrict.Filename)
|
log.Warnf("File mismatch: %s and %s", fileName, unrestrict.Filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cfg.ShouldServeFromRclone() {
|
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)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
} else {
|
} 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
|
// this is possible if there's only 1 streamable file in the torrent
|
||||||
// and then suddenly it's a rar file
|
// and then suddenly it's a rar file
|
||||||
actualExt := filepath.Ext(unrestrict.Filename)
|
actualExt := filepath.Ext(unrestrictFilename)
|
||||||
expectedExt := filepath.Ext(fileName)
|
expectedExt := filepath.Ext(lFilename)
|
||||||
if actualExt != expectedExt && unrestrict.Streamable != 1 {
|
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)
|
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 {
|
} else {
|
||||||
log.Warnf("Filename mismatch: %s and %s", fileName, unrestrict.Filename)
|
log.Warnf("Filename mismatch: %s and %s", fileName, unrestrict.Filename)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user