Fix access key set not updating properly

This commit is contained in:
Ben Sarmiento
2023-12-07 10:59:43 +01:00
parent 8fe1c3249d
commit 35bffc12f5
4 changed files with 33 additions and 21 deletions

View File

@@ -30,23 +30,29 @@ type ConfigInterface interface {
type ZurgConfig struct { type ZurgConfig struct {
Version string `yaml:"zurg" json:"-"` Version string `yaml:"zurg" json:"-"`
Token string `yaml:"token" json:"-"` Token string `yaml:"token" json:"-"`
Host string `yaml:"host" json:"host"` Host string `yaml:"host" json:"host"`
Port string `yaml:"port" json:"port"` Port string `yaml:"port" json:"port"`
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"` NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"` 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"` 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"` 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"` ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"`
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"` 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"` OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"`
UseDownloadCache bool `yaml:"use_download_cache" json:"use_download_cache"` ComputeNameHook string `yaml:"compute_name_hook" json:"compute_name_hook"`
DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"`
} }
func (z *ZurgConfig) GetConfig() ZurgConfig { func (z *ZurgConfig) GetConfig() ZurgConfig {
@@ -152,3 +158,7 @@ func (z *ZurgConfig) GetRateLimitSleepSeconds() int {
func (z *ZurgConfig) ShouldDeleteRarFiles() bool { func (z *ZurgConfig) ShouldDeleteRarFiles() bool {
return z.DeleteRarFiles return z.DeleteRarFiles
} }
func (z *ZurgConfig) GetComputeNameHook() string {
return z.ComputeNameHook
}

View File

@@ -53,6 +53,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
// removed // removed
strset.Difference(t.accessKeySet, freshKeys).Each(func(accessKey string) bool { strset.Difference(t.accessKeySet, freshKeys).Each(func(accessKey string) bool {
t.accessKeySet.Remove(accessKey)
t.Delete(accessKey, false) t.Delete(accessKey, false)
return true return true
}) })

View File

@@ -35,9 +35,9 @@ func (t *TorrentManager) repairAll() {
func (t *TorrentManager) Repair(torrent *Torrent) { func (t *TorrentManager) Repair(torrent *Torrent) {
_ = t.repairWorker.Submit(func() { _ = t.repairWorker.Submit(func() {
t.log.Info("Repairing torrent %s", torrent.AccessKey) t.log.Infof("Repairing torrent %s", torrent.AccessKey)
t.repair(torrent) t.repair(torrent)
t.log.Info("Finished repairing torrent %s", torrent.AccessKey) t.log.Infof("Finished repairing torrent %s", torrent.AccessKey)
}) })
var updatedPaths []string var updatedPaths []string

View File

@@ -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) unrestrict := torMgr.UnrestrictUntilOk(link)
if unrestrict == nil { if unrestrict == nil {
// log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link) // log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link)