bug
This commit is contained in:
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,
|
||||
|
||||
Reference in New Issue
Block a user