Reimplement deletes and marking files as broken
This commit is contained in:
@@ -27,17 +27,11 @@ func CheckFile(directory, torrentName, fileName string, w http.ResponseWriter, r
|
||||
}
|
||||
|
||||
file, ok := torrent.SelectedFiles.Get(fileName)
|
||||
if !ok {
|
||||
if !ok || file.IsDeleted {
|
||||
log.Warnf("Cannot find file %s from path %s", fileName, req.URL.Path)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if !strings.HasPrefix(file.Link, "http") {
|
||||
// This is a dead file, serve an alternate file
|
||||
log.Warnf("File %s is no longer available", fileName)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
contentType := getContentMimeType(fileName)
|
||||
contentLength := fmt.Sprintf("%d", file.Bytes)
|
||||
lastModified := file.Ended
|
||||
@@ -48,12 +42,6 @@ func CheckFile(directory, torrentName, fileName string, w http.ResponseWriter, r
|
||||
}
|
||||
|
||||
func CheckDownloadLink(download *realdebrid.Download, w http.ResponseWriter, req *http.Request, torMgr *torrent.TorrentManager, log *logutil.Logger) {
|
||||
if !strings.HasPrefix(download.Link, "http") {
|
||||
// This is a dead file, serve an alternate file
|
||||
log.Warnf("File %s is no longer available", download.Filename)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
contentType := getContentMimeType(download.Filename)
|
||||
contentLength := fmt.Sprintf("%d", download.Filesize)
|
||||
lastModified := download.Generated
|
||||
|
||||
Reference in New Issue
Block a user