Additional fixes on link checks
This commit is contained in:
@@ -112,7 +112,7 @@ func handleSingleTorrent(requestPath string, t *torrent.TorrentManager) ([]byte,
|
|||||||
sort.Strings(filenames)
|
sort.Strings(filenames)
|
||||||
for _, filename := range filenames {
|
for _, filename := range filenames {
|
||||||
file, _ := tor.SelectedFiles.Get(filename)
|
file, _ := tor.SelectedFiles.Get(filename)
|
||||||
if file == nil || file.Link == "" {
|
if file == nil || !strings.HasPrefix(file.Link, "http") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
responses = append(responses, dav.File(
|
responses = append(responses, dav.File(
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func handleSingleTorrent(requestPath string, t *torrent.TorrentManager) (*string
|
|||||||
sort.Strings(filenames)
|
sort.Strings(filenames)
|
||||||
for _, filename := range filenames {
|
for _, filename := range filenames {
|
||||||
file, _ := tor.SelectedFiles.Get(filename)
|
file, _ := tor.SelectedFiles.Get(filename)
|
||||||
if file == nil || file.Link == "" {
|
if file == nil || !strings.HasPrefix(file.Link, "http") {
|
||||||
// will be caught by torrent manager's repairAll
|
// will be caught by torrent manager's repairAll
|
||||||
// just skip it for now
|
// just skip it for now
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -141,10 +141,10 @@ func (t *TorrentManager) mergeToMain(mainTorrent, torrentToMerge *Torrent) *Torr
|
|||||||
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
||||||
} else {
|
} else {
|
||||||
// if it exists, compare the LatestAdded property and the link
|
// if it exists, compare the LatestAdded property and the link
|
||||||
if mainTorrent.LatestAdded < torrentToMerge.LatestAdded && fileToMerge.Link != "" {
|
if mainTorrent.LatestAdded < torrentToMerge.LatestAdded && strings.HasPrefix(fileToMerge.Link, "http") {
|
||||||
// if torrentToMerge is more recent and its file has a link, update the main torrent's file
|
// if torrentToMerge is more recent and its file has a link, update the main torrent's file
|
||||||
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
||||||
} else if mainFile.Link == "" && fileToMerge.Link != "" {
|
} else if !strings.HasPrefix(mainFile.Link, "http") && strings.HasPrefix(fileToMerge.Link, "http") {
|
||||||
// if the main torrent's file link is empty and t2's file has a link, even if it's older, update it
|
// if the main torrent's file link is empty and t2's file has a link, even if it's older, update it
|
||||||
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
||||||
}
|
}
|
||||||
@@ -590,7 +590,7 @@ func (t *TorrentManager) Repair(accessKey string) {
|
|||||||
ZurgFS: file.ZurgFS,
|
ZurgFS: file.ZurgFS,
|
||||||
}
|
}
|
||||||
selectedFiles = append(selectedFiles, fileCopy)
|
selectedFiles = append(selectedFiles, fileCopy)
|
||||||
if fileCopy.Link != "" {
|
if strings.HasPrefix(fileCopy.Link, "http") {
|
||||||
links = append(links, fileCopy.Link)
|
links = append(links, fileCopy.Link)
|
||||||
}
|
}
|
||||||
fileCopy.Link = "" // empty the links = chaos!
|
fileCopy.Link = "" // empty the links = chaos!
|
||||||
@@ -619,7 +619,7 @@ func (t *TorrentManager) Repair(accessKey string) {
|
|||||||
// if all the selected files are missing but there are other streamable files
|
// if all the selected files are missing but there are other streamable files
|
||||||
var missingFiles []File
|
var missingFiles []File
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if file.Link == "" {
|
if !strings.HasPrefix(file.Link, "http") {
|
||||||
missingFiles = append(missingFiles, *file)
|
missingFiles = append(missingFiles, *file)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -643,7 +643,7 @@ func (t *TorrentManager) reinsertTorrent(torrent *Torrent, missingFiles string)
|
|||||||
if missingFiles == "" {
|
if missingFiles == "" {
|
||||||
tmpSelection := ""
|
tmpSelection := ""
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if file.Link == "" {
|
if !strings.HasPrefix(file.Link, "http") {
|
||||||
tmpSelection += fmt.Sprintf("%d,", file.ID)
|
tmpSelection += fmt.Sprintf("%d,", file.ID)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *intTor.TorrentM
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.Link == "" {
|
if !strings.HasPrefix(file.Link, "http") {
|
||||||
// This is a dead file, serve an alternate file
|
// This is a dead file, serve an alternate file
|
||||||
log.Warnf("File %s is not yet available, zurg is repairing the torrent", filename)
|
log.Warnf("File %s is not yet available, zurg is repairing the torrent", filename)
|
||||||
streamErrorVideo("https://www.youtube.com/watch?v=bGTqwt6vdcY", w, r, t, c, log)
|
streamErrorVideo("https://www.youtube.com/watch?v=bGTqwt6vdcY", w, r, t, c, log)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torren
|
|||||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if file.Link == "" {
|
if !strings.HasPrefix(file.Link, "http") {
|
||||||
// This is a dead file, serve an alternate file
|
// This is a dead file, serve an alternate file
|
||||||
log.Warnf("File %s is no longer available", filename)
|
log.Warnf("File %s is no longer available", filename)
|
||||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (rd *RealDebrid) UnrestrictUntilOk(link string) *UnrestrictResponse {
|
func (rd *RealDebrid) UnrestrictUntilOk(link string) *UnrestrictResponse {
|
||||||
if link == "" {
|
if !strings.HasPrefix(link, "http") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
unrestrictFn := func(link string) (*UnrestrictResponse, error) {
|
unrestrictFn := func(link string) (*UnrestrictResponse, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user