From 37cd84d07bb3ad46c9c8ea6552ecd181900f625e Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Tue, 24 Oct 2023 22:19:43 +0200 Subject: [PATCH] Remove tests --- internal/http/get.go | 8 ++------ internal/torrent/manager.go | 17 ++++++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/internal/http/get.go b/internal/http/get.go index 5d1e8bd..e066389 100644 --- a/internal/http/get.go +++ b/internal/http/get.go @@ -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] diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index a94d84b..0c85f65 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -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 } }