Implement autoheal feature
This commit is contained in:
@@ -141,23 +141,19 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
||||
}
|
||||
resp := realdebrid.RetryUntilOk(unrestrictFn)
|
||||
if resp == nil {
|
||||
// TODO: Readd the file
|
||||
// when unrestricting fails, it means the file is not available anymore, but still in their database
|
||||
// if it's the only file, tough luck
|
||||
// if it's the only file, try to readd it
|
||||
// delete the old one, add a new one
|
||||
log.Println("Cannot unrestrict link", link, filenameV2)
|
||||
t.MarkFileAsDeleted(torrent, file)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if resp.Filename != filenameV2 {
|
||||
// TODO: Redo the logic to handle mismatch
|
||||
// [SRS] Pokemon S22E01-35 1080p WEBRip AAC 2.0 x264 CC.rar
|
||||
// Pokemon.S22E24.The.Secret.Princess.DUBBED.1080p.WEBRip.AAC.2.0.x264-SRS.mkv
|
||||
// Action: schedule a "cleanup" job for the parent torrent
|
||||
// If the file extension changed, that means it's a different file
|
||||
log.Println("Filename mismatch", resp.Filename, filenameV2)
|
||||
actualExt := filepath.Ext(resp.Filename)
|
||||
expectedExt := filepath.Ext(filenameV2)
|
||||
if actualExt != expectedExt {
|
||||
log.Println("File extension mismatch", resp.Filename, filenameV2)
|
||||
} else {
|
||||
log.Println("Filename mismatch", resp.Filename, filenameV2)
|
||||
}
|
||||
}
|
||||
cache.Add(requestPath, resp.Download)
|
||||
http.Redirect(w, r, resp.Download, http.StatusFound)
|
||||
|
||||
Reference in New Issue
Block a user