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