From 00e4f8013cdae6287ac8b30ab8feafe3bd2ae922 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 28 Jan 2024 03:48:53 +0100 Subject: [PATCH] Set filenames properly --- internal/app.go | 8 ++++---- internal/torrent/manager.go | 6 ++++-- internal/torrent/refresh.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/app.go b/internal/app.go index 50e28a5..458b470 100644 --- a/internal/app.go +++ b/internal/app.go @@ -29,15 +29,15 @@ func MainApp(configPath string) { log := logutil.NewLogger(logPath) zurglog := log.Named("zurg") - if log.Level() == zapcore.DebugLevel { - zurglog.Infof("debug logging is enabled; if you are not debugging please set LOG_LEVEL=info in your environment") - } - zurglog.Debugf("PID: %d", os.Getpid()) zurglog.Infof("Version: %s", version.GetVersion()) zurglog.Infof("GitCommit: %s", version.GetGitCommit()) zurglog.Infof("BuiltAt: %s", version.GetBuiltAt()) + if log.Level() == zapcore.DebugLevel { + zurglog.Infof("Debug logging is enabled; if you are not debugging please set LOG_LEVEL=info in your environment") + } + config, configErr := config.LoadZurgConfig(configPath, log.Named("config")) if configErr != nil { zurglog.Errorf("Config failed to load: %v", configErr) diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 3ad4afa..587b759 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -110,9 +110,11 @@ func (t *TorrentManager) GetKey(torrent *Torrent) string { func (t *TorrentManager) GetPath(file *File) string { if t.Config.ShouldExposeFullPath() { filename := strings.TrimPrefix(file.Path, "/") - return strings.ReplaceAll(filename, "/", " - ") + filename = strings.ReplaceAll(filename, "/", " - ") + return filename } - return filepath.Base(file.Path) + filename := filepath.Base(file.Path) + return filename } func (t *TorrentManager) writeTorrentToFile(instanceID string, torrent *Torrent) { diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index b6ee505..da9ea35 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -147,7 +147,6 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent { if torrentFromCache, exists := infoCache.Get(rdTorrent.ID); exists && !torrentFromCache.AnyInProgress() && torrentFromCache.SelectedFiles.Count() == len(rdTorrent.Links) { - t.ResetSelectedFiles(torrentFromCache) return torrentFromCache } @@ -165,6 +164,7 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent { if !hasBrokenFiles { infoCache.Set(rdTorrent.ID, torrentFromFile) + t.ResetSelectedFiles(torrentFromFile) return torrentFromFile } else { t.log.Warnf("Torrent %s has broken files, will not save on info cache", rdTorrent.ID)