mirror of https://github.com/perkeep/perkeep.git
Move blobref.ParseMulti to its sole caller, with error checking.
Change-Id: I6351591497879ea5a113bc8e8414b751b3d1c812
This commit is contained in:
parent
de00851493
commit
76013089a4
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue