feat: auto rename on duplicate (#76)

This commit is contained in:
Li Wei authored and GitHub committed 2023-02-10 15:18:31 +08:00
1 parent 048554df4d
commit 0515ce6081
8 files changed
+205 -152

No files matched your search

+9
View File
@@ -3,6 +3,7 @@ package fetcher
import (
"github.com/monkeyWie/gopeed/internal/controller"
"github.com/monkeyWie/gopeed/pkg/base"
"path"
)
// Fetcher defines the interface for a download protocol.
@@ -36,6 +37,14 @@ type FetcherMeta struct {
Opts *base.Options `json:"opts"`
}
func (m *FetcherMeta) Filepath(file *base.FileInfo) string {
finalName := m.Opts.Name
if finalName == "" {
finalName = file.Name
}
return path.Join(m.Opts.Path, m.Res.RootDir, finalName)
}
// FetcherBuilder defines the interface for a fetcher builder.
type FetcherBuilder interface {
// Schemes returns the schemes supported by the fetcher.