bug
This commit is contained in:
@@ -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
|
||||
|
||||
10
hardlink.go
10
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,
|
||||
|
||||
2
main.go
2
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user