1
0
mirror of https://github.com/fumiama/RVC-Models-Downloader.git synced 2025-01-19 04:26:43 +09:00

Compare commits

..

No commits in common. "main" and "v0.2.9" have entirely different histories.
main ... v0.2.9

3 changed files with 8 additions and 18 deletions

View File

@ -15,8 +15,6 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.22
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@master

View File

@ -33,7 +33,6 @@ func main() {
wait := flag.Uint("w", 4, "connection waiting seconds")
ua := flag.String("ua", defua, "customize user agent")
h := flag.Bool("h", false, "display this help")
home := flag.String("H", ".", "download under this path")
flag.BoolVar(&notui, "notui", false, "use plain text instead of TUI")
flag.Parse()
args := flag.Args()
@ -45,11 +44,6 @@ func main() {
fmt.Println(cmdlst.String())
return
}
err := os.MkdirAll(*home, 0755)
if err != nil {
logrus.Errorln("mkdirs of path", *home, "err:", err)
return
}
if notui {
logrus.Infoln("RVC Models Downloader start at", time.Now().Local().Format(time.DateTime+" (MST)"))
logrus.Infof("operating system: %s, architecture: %s", runtime.GOOS, runtime.GOARCH)
@ -95,7 +89,7 @@ func main() {
}
ch := make(chan struct{})
go func() {
err := usercfg.download(args[0], "", *home, *ua, time.Second*time.Duration(*wait), *cust, !*ntrs, *force)
err := usercfg.download(args[0], "", *ua, time.Second*time.Duration(*wait), *cust, !*ntrs, *force)
ch <- struct{}{}
if err != nil {
errorln(err)

16
net.go
View File

@ -5,7 +5,6 @@ import (
"io"
"net/http"
"os"
"path"
"runtime"
"strconv"
"strings"
@ -16,16 +15,16 @@ import (
"github.com/pkg/errors"
)
func (c *config) download(p, prefix, home, ua string, waits time.Duration, usecust, usetrs, force bool) error {
func (c *config) download(path, prefix, ua string, waits time.Duration, usecust, usetrs, force bool) error {
for i, t := range c.Targets {
if t.Refer != "" {
refp := p[:strings.LastIndex(p, "/")+1] + t.Refer
refp := path[:strings.LastIndex(path, "/")+1] + t.Refer
infof("#%s%d refer to target '%s'.", prefix, i+1, refp)
refcfg, err := readconfig(refp, usecust)
if err != nil {
return err
}
err = refcfg.download(refp, prefix+strconv.Itoa(i+1)+".", home, ua, waits, usecust, usetrs, force)
err = refcfg.download(refp, prefix+strconv.Itoa(i+1)+".", ua, waits, usecust, usetrs, force)
if err != nil {
return err
}
@ -39,12 +38,11 @@ func (c *config) download(p, prefix, home, ua string, waits time.Duration, usecu
warnf("#%s%d target required Arch: %s but you are %s, skip.", prefix, i+1, t.Arch, runtime.GOARCH)
continue
}
homefolder := path.Join(home, t.Folder)
err := os.MkdirAll(homefolder, 0755)
err := os.MkdirAll(t.Folder, 0755)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("#%s%d make target folder '%s'", prefix, i+1, homefolder))
return errors.Wrap(err, fmt.Sprintf("#%s%d make target folder '%s'", prefix, i+1, t.Folder))
}
infof("#%s%d open target folder '%s'.", prefix, i+1, homefolder)
infof("#%s%d open target folder '%s'.", prefix, i+1, t.Folder)
if len(t.Copy) == 0 {
warnf("#%s%d empty copy target.", prefix, i+1)
continue
@ -59,7 +57,7 @@ func (c *config) download(p, prefix, home, ua string, waits time.Duration, usecu
if sleep > time.Millisecond {
time.Sleep(sleep)
}
fname := path.Join(homefolder, cp[strings.LastIndex(cp, "/")+1:])
fname := t.Folder + "/" + cp[strings.LastIndex(cp, "/")+1:]
if !force {
if _, err := os.Stat(fname); err == nil || os.IsExist(err) {
warnf("#%s%d skip exist file %s", prefix, i+1, fname)