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/rocky-linux/srpmproc/pkg/srpmproc"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log" "log"
"os"
) )
var fetch = &cobra.Command{ var fetch = &cobra.Command{
@ -39,7 +40,12 @@ func init() {
} }
func runFetch(_ *cobra.Command, _ []string) { 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -12,14 +12,9 @@ import (
"strings" "strings"
) )
func Fetch(cdnUrl string) error { func Fetch(cdnUrl string, dir string) error {
wd, err := os.Getwd()
if err != nil {
return err
}
metadataPath := "" 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 strings.HasSuffix(path, ".metadata") {
if metadataPath != "" { if metadataPath != "" {
return errors.New("multiple metadata files") return errors.New("multiple metadata files")