repair fixes!
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
// HandleGetRequest handles a GET request universally for both WebDAV and HTTP
|
||||
func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *intTor.TorrentManager, c config.ConfigInterface, cache *expirable.LRU[string, string]) {
|
||||
log := logutil.NewLogger().Named("uniget")
|
||||
log := logutil.NewLogger().Named("file")
|
||||
|
||||
requestPath := path.Clean(r.URL.Path)
|
||||
isDav := true
|
||||
@@ -80,26 +80,27 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *intTor.TorrentM
|
||||
|
||||
resp := t.UnrestrictUntilOk(link)
|
||||
if resp == nil {
|
||||
log.Warnf("File %s is no longer available", file.Path)
|
||||
file.Link = ""
|
||||
t.SetChecksum("") // force a recheck
|
||||
log.Warnf("File %s is no longer available", file.Path)
|
||||
streamErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, t, c, log)
|
||||
return
|
||||
} else if resp.Filename != filename {
|
||||
// this is possible if there's only 1 streamable file in the torrent
|
||||
// and then suddenly it's a rar file
|
||||
actualExt := filepath.Ext(resp.Filename)
|
||||
expectedExt := filepath.Ext(filename)
|
||||
if actualExt != expectedExt && resp.Streamable != 1 {
|
||||
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.Warnf("Filename mismatch: %s and %s", filename, resp.Filename)
|
||||
} else {
|
||||
if resp.Filename != filename {
|
||||
// this is possible if there's only 1 streamable file in the torrent
|
||||
// and then suddenly it's a rar file
|
||||
actualExt := filepath.Ext(resp.Filename)
|
||||
expectedExt := filepath.Ext(filename)
|
||||
if actualExt != expectedExt && resp.Streamable != 1 {
|
||||
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.Warnf("Filename mismatch: %s and %s", filename, resp.Filename)
|
||||
}
|
||||
}
|
||||
cache.Add(requestPath, resp.Download)
|
||||
streamFileToResponse(file, resp.Download, w, r, t, c, log)
|
||||
}
|
||||
cache.Add(requestPath, resp.Download)
|
||||
streamFileToResponse(file, resp.Download, w, r, t, c, log)
|
||||
}
|
||||
|
||||
func streamFileToResponse(file *intTor.File, url string, w http.ResponseWriter, r *http.Request, torMgr *intTor.TorrentManager, cfg config.ConfigInterface, log *zap.SugaredLogger) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.TorrentManager, cache *expirable.LRU[string, string]) {
|
||||
log := logutil.NewLogger().Named("unihead")
|
||||
log := logutil.NewLogger().Named("head")
|
||||
|
||||
requestPath := path.Clean(r.URL.Path)
|
||||
requestPath = strings.Replace(requestPath, "/http", "", 1)
|
||||
|
||||
Reference in New Issue
Block a user