Remove tests
This commit is contained in:
@@ -60,7 +60,7 @@ func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torren
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if file.Link == "" {
|
if file.Link == "" {
|
||||||
log.Println("Link not found 222", filename)
|
log.Println("Link not found (head)", filename)
|
||||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if file.Link == "" {
|
if file.Link == "" {
|
||||||
log.Println("Link not found 33", filename)
|
log.Println("Link not found (get)", filename)
|
||||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -165,10 +165,6 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
|
|||||||
func getFile(torrents []torrent.Torrent, filename, fragment string) (*torrent.Torrent, *torrent.File) {
|
func getFile(torrents []torrent.Torrent, filename, fragment string) (*torrent.Torrent, *torrent.File) {
|
||||||
for t := range torrents {
|
for t := range torrents {
|
||||||
for f, file := range torrents[t].SelectedFiles {
|
for f, file := range torrents[t].SelectedFiles {
|
||||||
// fmt.Println("~~~~~~~~~~~~~~", torrents[t].Version)
|
|
||||||
if torrents[t].ID == "ABUNEKZP3UPMU" || torrents[t].ID == "TAA5WUJ6BVEAE" {
|
|
||||||
fmt.Println("~~~~~~~~~~~~~~", torrents[t].ID, torrents[t].Version, len(torrents[t].Links), len(file.Link))
|
|
||||||
}
|
|
||||||
fname := filepath.Base(file.Path)
|
fname := filepath.Base(file.Path)
|
||||||
if filename == fname && strings.Contains(file.Link, fragment) {
|
if filename == fname && strings.Contains(file.Link, fragment) {
|
||||||
return &torrents[t], &torrents[t].SelectedFiles[f]
|
return &torrents[t], &torrents[t].SelectedFiles[f]
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type TorrentManager struct {
|
|||||||
// and store them in-memory
|
// and store them in-memory
|
||||||
func NewTorrentManager(config config.ConfigInterface, cache *expirable.LRU[string, string]) *TorrentManager {
|
func NewTorrentManager(config config.ConfigInterface, cache *expirable.LRU[string, string]) *TorrentManager {
|
||||||
t := &TorrentManager{
|
t := &TorrentManager{
|
||||||
requiredVersion: "v2",
|
requiredVersion: "24.10.2023",
|
||||||
config: config,
|
config: config,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
workerPool: make(chan bool, config.GetNumOfWorkers()),
|
workerPool: make(chan bool, config.GetNumOfWorkers()),
|
||||||
@@ -95,11 +95,11 @@ func (t *TorrentManager) GetByDirectory(directory string) []Torrent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HideTheFile marks a file as deleted
|
// HideTheFile marks a file as deleted
|
||||||
func (t *TorrentManager) HideTheFile(torrent *Torrent, file *File) {
|
// func (t *TorrentManager) HideTheFile(torrent *Torrent, file *File) {
|
||||||
file.Link = ""
|
// file.Link = ""
|
||||||
t.writeToFile(torrent)
|
// t.writeToFile(torrent)
|
||||||
t.repair(torrent.ID, []File{*file}, false)
|
// t.repair(torrent.ID, []File{*file}, false)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// FindAllTorrentsWithName finds all torrents in a given directory with a given name
|
// FindAllTorrentsWithName finds all torrents in a given directory with a given name
|
||||||
func (t *TorrentManager) FindAllTorrentsWithName(directory, torrentName string) []Torrent {
|
func (t *TorrentManager) FindAllTorrentsWithName(directory, torrentName string) []Torrent {
|
||||||
@@ -253,16 +253,11 @@ func (t *TorrentManager) addMoreInfo(torrent *Torrent) {
|
|||||||
// file cache
|
// file cache
|
||||||
torrentFromFile := t.readFromFile(torrent.ID)
|
torrentFromFile := t.readFromFile(torrent.ID)
|
||||||
if torrentFromFile != nil {
|
if torrentFromFile != nil {
|
||||||
fmt.Println("from file!")
|
|
||||||
// see if api data and file data still match
|
// see if api data and file data still match
|
||||||
// then it means data is still usable
|
// then it means data is still usable
|
||||||
if len(torrentFromFile.Links) == len(torrent.Links) {
|
if len(torrentFromFile.Links) == len(torrent.Links) {
|
||||||
torrent.ForRepair = torrentFromFile.ForRepair
|
torrent.ForRepair = torrentFromFile.ForRepair
|
||||||
torrent.SelectedFiles = torrentFromFile.SelectedFiles[:]
|
torrent.SelectedFiles = torrentFromFile.SelectedFiles[:]
|
||||||
if torrentFromFile.ID == "ABUNEKZP3UPMU" || torrentFromFile.ID == "TAA5WUJ6BVEAE" {
|
|
||||||
fmt.Println(">>>>>>>>>>>>>>>>", torrentFromFile.ID, len(torrentFromFile.Links), len(torrent.Links), len(torrent.SelectedFiles[0].Link))
|
|
||||||
torrent.Version = "v2"
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user