From c326007d01b623bcf883f74f31fc3e5ab3078396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Fri, 26 Jun 2020 00:58:38 +0200 Subject: [PATCH] fix cache not rebuilding properly --- cache/repo_cache.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/cache/repo_cache.go b/cache/repo_cache.go index 83ce4802d43a691913a75ed628451588144eed47..e70904df80f8cc0e8b82c14123894085843e9e6c 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -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