(i *identity.Identity, metadata map[string]string)
| 97 | } |
| 98 | |
| 99 | func (c *RepoCacheIdentity) finishIdentity(i *identity.Identity, metadata map[string]string) (*IdentityCache, error) { |
| 100 | for key, value := range metadata { |
| 101 | i.SetMetadata(key, value) |
| 102 | } |
| 103 | |
| 104 | err := i.Commit(c.repo) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | c.mu.Lock() |
| 110 | if _, has := c.cached[i.Id()]; has { |
| 111 | return nil, fmt.Errorf("identity %s already exist in the cache", i.Id()) |
| 112 | } |
| 113 | |
| 114 | cached := NewIdentityCache(i, c.repo, c.entityUpdated) |
| 115 | c.cached[i.Id()] = cached |
| 116 | c.mu.Unlock() |
| 117 | |
| 118 | // force the write of the excerpt |
| 119 | err = c.entityUpdated(i.Id()) |
| 120 | if err != nil { |
| 121 | return nil, err |
| 122 | } |
| 123 | |
| 124 | return cached, nil |
| 125 | } |
no test coverage detected