This commit is contained in:
2026-04-09 21:12:10 +02:00
parent 083c66dca7
commit 72528be2b1
3 changed files with 11 additions and 5 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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)
}