Commit f5f8aff
authored
Automatically deleting corrupted Go module cache (#2194)
**What type of PR is this?**
Feature
**What package or component does this PR mostly affect?**
go_repository
**What does this PR do? Why is it needed?**
When the Go module sum mismatches, the most effective way is to delete
the corrupted Go module, instead of deleting the whole Go module cache,
which may contain many other unrelated modules. Because fetch_repo
already know where the Go module is, it can automatically delete it and
ask people to retry.
**Other notes for review**
New experience:
```
$ export GO_REPOSITORY_USE_HOST_CACHE=1
# intentionally corrupt a module
$ rm $(go env GOMODCACHE)/github.com/mattn/[email protected]/static_mock.go
$ bazel clean --expunge --async
$ bazel fetch --force @com_github_mattn_go_sqlite3//:go-sqlite3
...
ERROR: com_github_mattn_go_sqlite3: fetch_repo: resulting module with sum h1:NlqjV/4w2ZBKwamqKNXcb6I12S9NTFOi18B0VlNju6g=; expected sum h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=. Please try again. If the problem persists, please try clearing your host module cache with `go clean -modcache`
```1 parent a0a42d4 commit f5f8aff
1 file changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
68 | 76 | | |
69 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | | - | |
| 81 | + | |
72 | 82 | | |
73 | 83 | | |
74 | 84 | | |
| |||
0 commit comments