From b231d0deabf8c5e5def785e65d4d62d9355fbcd4 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 21 Sep 2021 03:46:51 +0800 Subject: Ignore Sync errors on pipes when doing `CheckAttributeReader.CheckPath`, fix the hang of `git cat-file` (#17096) * Ignore Sync errors on pipes when doing `CheckAttributeReader.CheckPath` * apply env patch * Drop the Sync and fix a number of issues with the Close function Signed-off-by: Andrew Thornton * add logs for DBIndexer and CheckPath * Fix some more closing bugs Signed-off-by: Andrew Thornton * Add test case for language_stats Signed-off-by: Andrew Thornton * Update modules/indexer/stats/db.go Co-authored-by: Lauris BH Co-authored-by: Andrew Thornton Co-authored-by: Lauris BH Co-authored-by: 6543 <6543@obermui.de> --- modules/indexer/stats/db.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'modules/indexer') diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go index 976bf2d632..87e8677a28 100644 --- a/modules/indexer/stats/db.go +++ b/modules/indexer/stats/db.go @@ -38,11 +38,11 @@ func (db *DBIndexer) Index(id int64) error { // Get latest commit for default branch commitID, err := gitRepo.GetBranchCommitID(repo.DefaultBranch) if err != nil { - if git.IsErrBranchNotExist(err) || git.IsErrNotExist((err)) { - log.Debug("Unable to get commit ID for defaultbranch %s in %s ... skipping this repository", repo.DefaultBranch, repo.RepoPath()) + if git.IsErrBranchNotExist(err) || git.IsErrNotExist(err) { + log.Debug("Unable to get commit ID for default branch %s in %s ... skipping this repository", repo.DefaultBranch, repo.RepoPath()) return nil } - log.Error("Unable to get commit ID for defaultbranch %s in %s. Error: %v", repo.DefaultBranch, repo.RepoPath(), err) + log.Error("Unable to get commit ID for default branch %s in %s. Error: %v", repo.DefaultBranch, repo.RepoPath(), err) return err } @@ -54,10 +54,17 @@ func (db *DBIndexer) Index(id int64) error { // Calculate and save language statistics to database stats, err := gitRepo.GetLanguageStats(commitID) if err != nil { - log.Error("Unable to get language stats for ID %s for defaultbranch %s in %s. Error: %v", commitID, repo.DefaultBranch, repo.RepoPath(), err) + log.Error("Unable to get language stats for ID %s for default branch %s in %s. Error: %v", commitID, repo.DefaultBranch, repo.RepoPath(), err) return err } - return repo.UpdateLanguageStats(commitID, stats) + err = repo.UpdateLanguageStats(commitID, stats) + if err != nil { + log.Error("Unable to update language stats for ID %s for default branch %s in %s. Error: %v", commitID, repo.DefaultBranch, repo.RepoPath(), err) + return err + } + + log.Debug("DBIndexer completed language stats for ID %s for default branch %s in %s. stats count: %d", commitID, repo.DefaultBranch, repo.RepoPath(), len(stats)) + return nil } // Close dummy function -- cgit v1.2.3