Skip to content

Commit

Permalink
enhancement: add option to modify fetch path
Browse files Browse the repository at this point in the history
  • Loading branch information
mstg committed Sep 3, 2021
1 parent fb33e72 commit f6c9dba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 7 additions & 1 deletion cmd/srpmproc/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"github.com/spf13/cobra"
"log"
"os"
)

var fetch = &cobra.Command{
Expand All @@ -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)
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/srpmproc/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f6c9dba

Please sign in to comment.