fix cache not rebuilding properly

This commit is contained in:
Michael Muré 2020-06-26 00:58:38 +02:00
parent aab3a04d0c
commit c326007d01
No known key found for this signature in database
GPG Key ID: A4457C029293126F

23
cache/repo_cache.go vendored
View File

@ -32,14 +32,6 @@ const identityCacheFile = "identity-cache"
// 3: CreateUnixTime --> createUnixTime, EditUnixTime --> editUnixTime
const formatVersion = 3
type ErrInvalidCacheFormat struct {
message string
}
func (e ErrInvalidCacheFormat) Error() string {
return e.message
}
var _ repository.RepoCommon = &RepoCache{}
// RepoCache is a cache for a Repository. This cache has multiple functions:
@ -100,13 +92,8 @@ func NewNamedRepoCache(r repository.ClockedRepo, name string) (*RepoCache, error
if err == nil {
return c, nil
}
if _, ok := err.(ErrInvalidCacheFormat); !ok {
// Actual error
return nil, err
}
// We have an outdated cache format, rebuilding it.
// Cache is either missing, broken or outdated. Rebuilding.
err = c.buildCache()
if err != nil {
return nil, err
@ -259,9 +246,7 @@ func (c *RepoCache) loadBugCache() error {
}
if aux.Version != formatVersion {
return ErrInvalidCacheFormat{
message: fmt.Sprintf("unknown cache format version %v", aux.Version),
}
return fmt.Errorf("unknown cache format version %v", aux.Version)
}
c.bugExcerpts = aux.Excerpts
@ -291,9 +276,7 @@ func (c *RepoCache) loadIdentityCache() error {
}
if aux.Version != formatVersion {
return ErrInvalidCacheFormat{
message: fmt.Sprintf("unknown cache format version %v", aux.Version),
}
return fmt.Errorf("unknown cache format version %v", aux.Version)
}
c.identitiesExcerpts = aux.Excerpts