Move blobref.ParseMulti to its sole caller, with error checking.

Change-Id: I6351591497879ea5a113bc8e8414b751b3d1c812
This commit is contained in:
Brad Fitzpatrick 2013-07-07 11:46:21 -07:00
parent de00851493
commit 76013089a4
2 changed files with 9 additions and 10 deletions

View File

@ -44,5 +44,13 @@ func (c *removeCmd) RunCommand(args []string) error {
if len(args) == 0 {
return cmdmain.ErrUsage
}
return getUploader().RemoveBlobs(blobref.ParseMulti(args))
refs := make([]*blobref.BlobRef, 0, len(args))
for _, s := range args {
br := blobref.Parse(s)
if br == nil {
return fmt.Errorf("Invalid blobref %q", s)
}
refs = append(refs, br)
}
return getUploader().RemoveBlobs(refs)
}

View File

@ -240,12 +240,3 @@ func MustParse(ref string) *BlobRef {
}
return br
}
// May return nil in list positions where the blobref could not be parsed.
func ParseMulti(refs []string) (parsed []*BlobRef) {
parsed = make([]*BlobRef, 0, len(refs))
for _, ref := range refs {
parsed = append(parsed, Parse(ref))
}
return
}