Index returns the root image index for the cache. All attempts to read the index *must* use this function, so that it will lock the cache to prevent concurrent access. The underlying library writes modifications directly to the index, so not only must ensure that that only one process is writing at
()
| 44 | // so not only must ensure that that only one process is writing at a time, but that no one is reading |
| 45 | // while we are writing, to avoid corruption. |
| 46 | func (p *Provider) Index() (v1.ImageIndex, error) { |
| 47 | if p.Lock() != nil { |
| 48 | return nil, fmt.Errorf("unable to lock cache %s", p.dir) |
| 49 | } |
| 50 | defer p.Unlock() |
| 51 | return p.cache.ImageIndex() |
| 52 | } |
| 53 | |
| 54 | // Lock locks the cache directory to prevent concurrent access |
| 55 | func (p *Provider) Lock() error { |
no test coverage detected