# Cache: fix race condition · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/fae6290387850bfddbe4e9c1255750a65568b763)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: fae6290387850bfddbe4e9c1255750a65568b763

Requested commit: fae6290387850bfddbe4e9c1255750a65568b763

Commit: fae6290387850bfddbe4e9c1255750a65568b763

Tree: 3812c9ca4ee0436fe3dd77b1d7b237313fb666bb

Author: Jacob Young

Committer: Jacob Young

## Message

```
Cache: fix race condition

When checking a cache entry with no input files for a hit, if
`createFile` returned `error.WouldBlock` we would forget about the fact
that the file has been created, and all future checks will assume that a
cache hit has happened, even though one never has or does, leading to
rare `FileNotFound` errors trying the access the protected files.

This fix works by writing an extra byte to the manifest file to
distinguish hits and misses when there no input files to write.

```

## Parents

- [2d2d79a05b8423c7638348dc5a89793c1e0cafce](https://git.cafe/gitcafe/zig/commit/2d2d79a05b8423c7638348dc5a89793c1e0cafce?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/fae6290387850bfddbe4e9c1255750a65568b763?format=markdown)
