Lock locks the cache directory to prevent concurrent access
()
| 53 | |
| 54 | // Lock locks the cache directory to prevent concurrent access |
| 55 | func (p *Provider) Lock() error { |
| 56 | p.lockMut.Lock() |
| 57 | defer p.lockMut.Unlock() |
| 58 | |
| 59 | // if the lock is already set, we do not need to do anything |
| 60 | if p.lock != nil { |
| 61 | return nil |
| 62 | } |
| 63 | var lockFile = filepath.Join(p.dir, lockfile) |
| 64 | lock, err := util.Lock(lockFile) |
| 65 | if err != nil { |
| 66 | return fmt.Errorf("unable to retrieve cache lock %s: %v", lockFile, err) |
| 67 | } |
| 68 | p.lock = lock |
| 69 | return nil |
| 70 | } |
| 71 | |
| 72 | // Unlock releases the lock on the cache directory |
| 73 | func (p *Provider) Unlock() { |
no test coverage detected