From f346802da952111f048a6204c014391bb9548fca Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 27 May 2016 11:47:30 -0700 Subject: [PATCH] Adjust the signature of Fetch to include the "repo name" --- manifest/fetch.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/manifest/fetch.go b/manifest/fetch.go index 84cf7ea..f51e887 100644 --- a/manifest/fetch.go +++ b/manifest/fetch.go @@ -3,11 +3,14 @@ package manifest import ( "os" "net/http" + "path" "path/filepath" ) // "dir" is the default "library directory"; returns the parsed version of (in order) the file "repo", the file "dir/repo", or the remote file fetched from the URL "repo" -func Fetch(dir, repo string) (*Manifest2822, error) { +func Fetch(dir, repo string) (string, *Manifest2822, error) { + repoName := path.Base(repo) + // try file paths first for _, fileName := range []string{ repo, @@ -15,21 +18,23 @@ func Fetch(dir, repo string) (*Manifest2822, error) { } { f, err := os.Open(fileName) if err != nil && !os.IsNotExist(err) { - return nil, err + return repoName, nil, err } if err == nil { defer f.Close() - return Parse(f) + man, err := Parse(f) + return repoName, man, err } } // must be remote URL resp, err := http.Get(repo) if err != nil { - return nil, err + return repoName, nil, err } defer resp.Body.Close() - return Parse(resp.Body) + man, err := Parse(resp.Body) + return repoName, man, err - //return nil, fmt.Errorf("unable to find a manifest named %q (in %q or as a remote URL)", repo, dir) + //return repoName, nil, fmt.Errorf("unable to find a manifest named %q (in %q or as a remote URL)", repo, dir) }