Allow to retain repair status and unselect status
This commit is contained in:
@@ -143,7 +143,7 @@ func (t *TorrentManager) mergeToMain(mainTorrent, torrentToMerge *Torrent) *Torr
|
|||||||
// Merge SelectedFiles - itercb accesses a different copy of the selectedfiles map
|
// Merge SelectedFiles - itercb accesses a different copy of the selectedfiles map
|
||||||
torrentToMerge.SelectedFiles.IterCb(func(filepath string, fileToMerge *File) {
|
torrentToMerge.SelectedFiles.IterCb(func(filepath string, fileToMerge *File) {
|
||||||
// see if it already exists in the main torrent
|
// see if it already exists in the main torrent
|
||||||
if mainFile, ok := mainTorrent.SelectedFiles.Get(filepath); !ok {
|
if _, ok := mainTorrent.SelectedFiles.Get(filepath); !ok {
|
||||||
// if it doesn't exist in the main torrent, add it
|
// if it doesn't exist in the main torrent, add it
|
||||||
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
||||||
} else {
|
} else {
|
||||||
@@ -151,9 +151,6 @@ func (t *TorrentManager) mergeToMain(mainTorrent, torrentToMerge *Torrent) *Torr
|
|||||||
if mainTorrent.LatestAdded < torrentToMerge.LatestAdded && strings.HasPrefix(fileToMerge.Link, "http") {
|
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 !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
|
|
||||||
mainTorrent.SelectedFiles.Set(filepath, fileToMerge)
|
|
||||||
}
|
}
|
||||||
// else do nothing, the main torrent's file is more recent or has a valid link
|
// else do nothing, the main torrent's file is more recent or has a valid link
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ func (gf *GetFile) HandleGetRequest(w http.ResponseWriter, r *http.Request, t *i
|
|||||||
|
|
||||||
resp := t.UnrestrictUntilOk(link)
|
resp := t.UnrestrictUntilOk(link)
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
log.Warnf("File %s is no longer available", filepath.Base(file.Path))
|
log.Warnf("File %s is no longer available, file is marked for repair", filepath.Base(file.Path))
|
||||||
file.Link = "repair"
|
file.Link = "repair"
|
||||||
t.SetChecksum("") // force a recheck
|
t.SetChecksum("") // force a recheck
|
||||||
gf.playErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, t, c, log)
|
gf.playErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, t, c, log)
|
||||||
@@ -140,7 +140,7 @@ func (gf *GetFile) streamFileToResponse(file *intTor.File, url string, w http.Re
|
|||||||
resp, err := gf.client.Do(req)
|
resp, err := gf.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if file != nil {
|
if file != nil {
|
||||||
log.Warnf("Cannot download file %s: %v", file.Path, err)
|
log.Warnf("Cannot download file %s, file is marked for repair: %v", file.Path, err)
|
||||||
file.Link = "repair"
|
file.Link = "repair"
|
||||||
torMgr.SetChecksum("") // force a recheck
|
torMgr.SetChecksum("") // force a recheck
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ func (gf *GetFile) streamFileToResponse(file *intTor.File, url string, w http.Re
|
|||||||
|
|
||||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
||||||
if file != nil {
|
if file != nil {
|
||||||
log.Warnf("Received a %s status code for file %s", resp.Status, file.Path)
|
log.Warnf("Received a %s status code for file %s, file is marked for repair", resp.Status, file.Path)
|
||||||
file.Link = "repair"
|
file.Link = "repair"
|
||||||
torMgr.SetChecksum("") // force a recheck
|
torMgr.SetChecksum("") // force a recheck
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user