Remove cache if build fails

i think it'd be better to do something like change the return to be (err error), i.e., named returned value, and then add a defer statement here like:
```
defer func() {
  if err != nil {
    flushCache(buildStore, repo.CommitID)
  }
}
```

This way, if any other error conditions are added in the future, the defer will catch them automatically