fixes here and there
This commit is contained in:
@@ -47,14 +47,14 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
||||
|
||||
torrent, _ := t.TorrentMap.Get(accessKey)
|
||||
if torrent == nil {
|
||||
log.Errorf("Cannot find torrent %s in the directory %s", accessKey, baseDirectory)
|
||||
log.Warnf("Cannot find torrent %s in the directory %s", accessKey, baseDirectory)
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
file, _ := torrent.SelectedFiles.Get(filename)
|
||||
if file == nil {
|
||||
log.Errorf("Cannot find file from path %s", requestPath)
|
||||
log.Warnf("Cannot find file from path %s", requestPath)
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
||||
|
||||
if file.Link == "" {
|
||||
// This is a dead file, serve an alternate file
|
||||
log.Errorf("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)
|
||||
return
|
||||
}
|
||||
@@ -75,18 +75,18 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
||||
resp := t.UnrestrictUntilOk(link)
|
||||
if resp == nil {
|
||||
go t.Repair(torrent.AccessKey)
|
||||
log.Errorf("File %s is no longer available, torrent is marked for repair", file.Path)
|
||||
log.Warnf("File %s is no longer available, torrent is marked for repair", file.Path)
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, t, c, log)
|
||||
return
|
||||
} else if resp.Filename != filename {
|
||||
actualExt := filepath.Ext(resp.Filename)
|
||||
expectedExt := filepath.Ext(filename)
|
||||
if actualExt != expectedExt && resp.Streamable != 1 {
|
||||
log.Errorf("File extension mismatch: %s and %s", filename, resp.Filename)
|
||||
log.Warnf("File was changed and is not streamable: %s and %s", filename, resp.Filename)
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=t9VgOriBHwE", w, r, t, c, log)
|
||||
return
|
||||
} else {
|
||||
log.Errorf("Filename mismatch: %s and %s", filename, resp.Filename)
|
||||
log.Warnf("Filename mismatch: %s and %s", filename, resp.Filename)
|
||||
}
|
||||
}
|
||||
cache.Add(requestPath, resp.Download)
|
||||
@@ -108,11 +108,11 @@ func streamFileToResponse(torrent *torrent.Torrent, url string, w http.ResponseW
|
||||
}
|
||||
|
||||
// Create a custom HTTP client
|
||||
client := zurghttp.NewHTTPClient(c.GetToken(), 10)
|
||||
client := zurghttp.NewHTTPClient(c.GetToken(), 10, c)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Errorf("Error downloading file %v ; torrent is marked for repair", err)
|
||||
log.Warnf("Cannot download file %v ; torrent is marked for repair", err)
|
||||
if torrent != nil {
|
||||
go t.Repair(torrent.AccessKey)
|
||||
}
|
||||
@@ -122,7 +122,7 @@ func streamFileToResponse(torrent *torrent.Torrent, url string, w http.ResponseW
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
||||
log.Errorf("Received a %s status code ; torrent is marked for repair", resp.Status)
|
||||
log.Warnf("Received a %s status code ; torrent is marked for repair", resp.Status)
|
||||
if torrent != nil {
|
||||
go t.Repair(torrent.AccessKey)
|
||||
}
|
||||
|
||||
@@ -46,20 +46,20 @@ func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torren
|
||||
|
||||
torrent, _ := t.TorrentMap.Get(accessKey)
|
||||
if torrent == nil {
|
||||
log.Errorf("Cannot find torrent %s in the directory %s", accessKey, baseDirectory)
|
||||
log.Warnf("Cannot find torrent %s in the directory %s", accessKey, baseDirectory)
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
file, _ := torrent.SelectedFiles.Get(filename)
|
||||
if file == nil {
|
||||
log.Errorf("Cannot find file from path %s", requestPath)
|
||||
log.Warnf("Cannot find file from path %s", requestPath)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if file.Link == "" {
|
||||
// This is a dead file, serve an alternate file
|
||||
log.Errorf("File %s is no longer available", filename)
|
||||
log.Warnf("File %s is no longer available", filename)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user