From 35bffc12f5085412d4b95546f4af64163efc4673 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Thu, 7 Dec 2023 10:59:43 +0100 Subject: [PATCH] Fix access key set not updating properly --- internal/config/types.go | 48 ++++++++++++++++++++++--------------- internal/torrent/refresh.go | 1 + internal/torrent/repair.go | 4 ++-- internal/universal/get.go | 1 + 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/internal/config/types.go b/internal/config/types.go index 43157d9..f1847a6 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -28,25 +28,31 @@ type ConfigInterface interface { } type ZurgConfig struct { - Version string `yaml:"zurg" json:"-"` - Token string `yaml:"token" json:"-"` - Host string `yaml:"host" json:"host"` - Port string `yaml:"port" json:"port"` - NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"` - RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"` - CanRepair bool `yaml:"enable_repair" json:"enable_repair"` - OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"` - NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"` - RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"` - RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"` - RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"` - PreferredHosts []string `yaml:"preferred_hosts" json:"preferred_hosts"` - ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"` - ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"` - RealDebridTimeout int `yaml:"realdebrid_timeout_secs" json:"realdebrid_timeout_secs"` - RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"` - UseDownloadCache bool `yaml:"use_download_cache" json:"use_download_cache"` - DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"` + Version string `yaml:"zurg" json:"-"` + Token string `yaml:"token" json:"-"` + + Host string `yaml:"host" json:"host"` + Port string `yaml:"port" json:"port"` + NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"` + RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"` + + RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"` + RetainFolderNameExtension bool `yaml:"retain_folder_name_extension" json:"retain_folder_name_extension"` + + CanRepair bool `yaml:"enable_repair" json:"enable_repair"` + DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"` + + RealDebridTimeout int `yaml:"realdebrid_timeout_secs" json:"realdebrid_timeout_secs"` + UseDownloadCache bool `yaml:"use_download_cache" json:"use_download_cache"` + RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"` + RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"` + PreferredHosts []string `yaml:"preferred_hosts" json:"preferred_hosts"` + NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"` + ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"` + ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"` + + OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"` + ComputeNameHook string `yaml:"compute_name_hook" json:"compute_name_hook"` } func (z *ZurgConfig) GetConfig() ZurgConfig { @@ -152,3 +158,7 @@ func (z *ZurgConfig) GetRateLimitSleepSeconds() int { func (z *ZurgConfig) ShouldDeleteRarFiles() bool { return z.DeleteRarFiles } + +func (z *ZurgConfig) GetComputeNameHook() string { + return z.ComputeNameHook +} diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index cb55fb1..04937f4 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -53,6 +53,7 @@ func (t *TorrentManager) RefreshTorrents() []string { // removed strset.Difference(t.accessKeySet, freshKeys).Each(func(accessKey string) bool { + t.accessKeySet.Remove(accessKey) t.Delete(accessKey, false) return true }) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index e5321bc..aa6e1ee 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -35,9 +35,9 @@ func (t *TorrentManager) repairAll() { func (t *TorrentManager) Repair(torrent *Torrent) { _ = t.repairWorker.Submit(func() { - t.log.Info("Repairing torrent %s", torrent.AccessKey) + t.log.Infof("Repairing torrent %s", torrent.AccessKey) t.repair(torrent) - t.log.Info("Finished repairing torrent %s", torrent.AccessKey) + t.log.Infof("Finished repairing torrent %s", torrent.AccessKey) }) var updatedPaths []string diff --git a/internal/universal/get.go b/internal/universal/get.go index 3d46783..35d7dec 100644 --- a/internal/universal/get.go +++ b/internal/universal/get.go @@ -65,6 +65,7 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res } } + log.Debugf("Opening file %s from torrent %s (%s)", fileName, torrentName, link) unrestrict := torMgr.UnrestrictUntilOk(link) if unrestrict == nil { // log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link)