enhancement: add option to modify fetch path

This commit is contained in:
Mustafa Gezen 2021-09-03 23:52:04 +02:00
parent fb33e724c0
commit f6c9dba678
Signed by: mustafa
GPG Key ID: DCDF010D946438C1
2 changed files with 9 additions and 8 deletions

View File

@ -24,6 +24,7 @@ import (
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"github.com/spf13/cobra"
"log"
"os"
)
var fetch = &cobra.Command{
@ -39,7 +40,12 @@ func init() {
}
func runFetch(_ *cobra.Command, _ []string) {
err := srpmproc.Fetch(cdnUrl)
wd, err := os.Getwd()
if err != nil {
log.Fatalf("could not get working directory: %v", err)
}
err = srpmproc.Fetch(cdnUrl, wd)
if err != nil {
log.Fatal(err)
}

View File

@ -12,14 +12,9 @@ import (
"strings"
)
func Fetch(cdnUrl string) error {
wd, err := os.Getwd()
if err != nil {
return err
}
func Fetch(cdnUrl string, dir string) error {
metadataPath := ""
err = filepath.Walk(wd, func(path string, info os.FileInfo, err error) error {
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, ".metadata") {
if metadataPath != "" {
return errors.New("multiple metadata files")