From 72528be2b1934cbfbb8d17b69e8a5ccfae774503 Mon Sep 17 00:00:00 2001 From: rouggy Date: Thu, 9 Apr 2026 21:12:10 +0200 Subject: [PATCH] bug --- config.example.yaml | 4 ++-- hardlink.go | 10 ++++++++-- main.go | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index 4196ec1..e83d56b 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -5,6 +5,6 @@ dest_base: /home/rouggy/torrents/qbittorrent/Complete # Ajouter autant de catégories que nécessaire categories: Radarr: Movies - Radarr4K: Movies-4K + Radarr4K: 4K-Movies Sonarr: Series - Sonarr4K: Series-4K + Sonarr4K: 4K-Series diff --git a/hardlink.go b/hardlink.go index 0d1d572..800791a 100644 --- a/hardlink.go +++ b/hardlink.go @@ -10,7 +10,8 @@ import ( // processHardlinks creates hardlinks in destBase/destSubdir mirroring the // structure found at contentPath (either a single file or a directory tree). -func processHardlinks(cfg *Config, contentPath, destSubdir string) error { +// torrentName is used as the subdirectory name for single-file torrents. +func processHardlinks(cfg *Config, contentPath, destSubdir, torrentName string) error { info, err := os.Stat(contentPath) if err != nil { return fmt.Errorf("stat %q: %w", contentPath, err) @@ -22,7 +23,12 @@ func processHardlinks(cfg *Config, contentPath, destSubdir string) error { // Preserve the source directory name inside destDir return hardlinkDir(contentPath, filepath.Join(destDir, filepath.Base(contentPath))) } - return hardlinkFile(contentPath, filepath.Join(destDir, filepath.Base(contentPath))) + // Single-file torrent: place the file inside a subdirectory named after the torrent + subdir := torrentName + if subdir == "" { + subdir = filepath.Base(contentPath) + } + return hardlinkFile(contentPath, filepath.Join(destDir, subdir, filepath.Base(contentPath))) } // hardlinkDir walks srcDir and recreates the directory tree under destDir, diff --git a/main.go b/main.go index 42a1abb..3d5fa53 100644 --- a/main.go +++ b/main.go @@ -82,7 +82,7 @@ func main() { log.Printf("category %q -> dest subdir %q", *category, destSubdir) - if err := processHardlinks(cfg, *contentPath, destSubdir); err != nil { + if err := processHardlinks(cfg, *contentPath, destSubdir, *name); err != nil { log.Fatalf("error: %v", err) }