ByUUID looks up repository by uuid
(uuid string)
| 980 | |
| 981 | // ByUUID looks up repository by uuid |
| 982 | func (collection *RemoteRepoCollection) ByUUID(uuid string) (*RemoteRepo, error) { |
| 983 | if r, ok := collection.cache[uuid]; ok { |
| 984 | return r, nil |
| 985 | } |
| 986 | |
| 987 | key := (&RemoteRepo{UUID: uuid}).Key() |
| 988 | |
| 989 | value, err := collection.db.Get(key) |
| 990 | if err == database.ErrNotFound { |
| 991 | return nil, fmt.Errorf("mirror with uuid %s not found", uuid) |
| 992 | } |
| 993 | if err != nil { |
| 994 | return nil, err |
| 995 | } |
| 996 | |
| 997 | r := &RemoteRepo{} |
| 998 | err = r.Decode(value) |
| 999 | |
| 1000 | if err == nil { |
| 1001 | collection.cache[r.UUID] = r |
| 1002 | } |
| 1003 | |
| 1004 | return r, err |
| 1005 | } |
| 1006 | |
| 1007 | // ForEach runs method for each repository |
| 1008 | func (collection *RemoteRepoCollection) ForEach(handler func(*RemoteRepo) error) error { |