summaryrefslogtreecommitdiffstats
path: root/modules/indexer
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-09-21 03:46:51 +0800
committerGitHub <noreply@github.com>2021-09-20 20:46:51 +0100
commitb231d0deabf8c5e5def785e65d4d62d9355fbcd4 (patch)
tree9f88080296bf87e2d639b6c24d4503e0ab045d75 /modules/indexer
parent5ac857f4d43a8452089e22c820bd1f0ddb001b7a (diff)
downloadgitea-b231d0deabf8c5e5def785e65d4d62d9355fbcd4.tar.gz
gitea-b231d0deabf8c5e5def785e65d4d62d9355fbcd4.zip
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 <art27@cantab.net> * add logs for DBIndexer and CheckPath * Fix some more closing bugs Signed-off-by: Andrew Thornton <art27@cantab.net> * Add test case for language_stats Signed-off-by: Andrew Thornton <art27@cantab.net> * Update modules/indexer/stats/db.go Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/indexer')
-rw-r--r--modules/indexer/stats/db.go17
1 files changed, 12 insertions, 5 deletions
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