From b0d5bb909b2e558bee5d4d58f201012d5f8b4c1c Mon Sep 17 00:00:00 2001 From: Ethan Koenig Date: Wed, 17 Jan 2018 13:51:07 -0800 Subject: Delete indexer DB entries when (re)creating index (#3385) * comment --- models/repo_indexer.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'models') diff --git a/models/repo_indexer.go b/models/repo_indexer.go index 41c9f0fa31..be409f5162 100644 --- a/models/repo_indexer.go +++ b/models/repo_indexer.go @@ -86,6 +86,13 @@ func populateRepoIndexerAsynchronously() error { return nil } + // if there is any existing repo indexer metadata in the DB, delete it + // since we are starting afresh. Also, xorm requires deletes to have a + // condition, and we want to delete everything, thus 1=1. + if _, err := x.Where("1=1").Delete(new(RepoIndexerStatus)); err != nil { + return err + } + var maxRepoID int64 if _, err = x.Select("MAX(id)").Table("repository").Get(&maxRepoID); err != nil { return err -- cgit v1.2.3