From 2440a208f6e0d18f67f4e022b1c28996ee226af0 Mon Sep 17 00:00:00 2001 From: vince Date: Wed, 26 Aug 2020 09:04:40 +0800 Subject: [PATCH] Fix bugs and cleanup code --- cache/repo_cache.go | 4 ++-- cache/repo_cache_bug.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cache/repo_cache.go b/cache/repo_cache.go index d13ce65c0cb9e2031f16a45762f38afa86845777..563fac6b5059ddc0608ff870852ae4d0b2f1fc8e 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -22,7 +22,7 @@ import ( const formatVersion = 2 // The maximum number of bugs loaded in memory. After that, eviction will be done. -const defaultMaxLoadedBugs = 100 +const defaultMaxLoadedBugs = 1000 var _ repository.RepoCommon = &RepoCache{} @@ -160,7 +160,7 @@ func (c *RepoCache) Close() error { c.identities = make(map[entity.Id]*IdentityCache) c.identitiesExcerpts = nil - c.bugs = nil + c.bugs = make(map[entity.Id]*BugCache) c.bugExcerpts = nil lockPath := repoLockFilePath(c.repo) diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go index cd60eac176f30330100370144a2f1cff41eaf3a3..37b91c548b8c2fc9dbe1dc4b1b5085c336ec7ccc 100644 --- a/cache/repo_cache_bug.go +++ b/cache/repo_cache_bug.go @@ -119,7 +119,7 @@ func (c *RepoCache) ResolveBugExcerpt(id entity.Id) (*BugExcerpt, error) { excerpt, ok := c.bugExcerpts[id] if !ok { - panic("missing bug in the cache") + return nil, bug.ErrBugNotExist } return excerpt, nil