From f1c6cf7c51929406a198ec35403fc3ea790ebeb3 Mon Sep 17 00:00:00 2001
From: zeripath <art27@cantab.net>
Date: Fri, 25 Feb 2022 04:22:09 +0000
Subject: [PATCH] Prevent Stats Indexer reporting error if repo dir missing
 (#18870)

Repositories missing their directory should not report an error from the stats
indexer.

Close #18847

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
---
 modules/indexer/stats/db.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go
index e425b95d20..513f2270da 100644
--- a/modules/indexer/stats/db.go
+++ b/modules/indexer/stats/db.go
@@ -37,6 +37,9 @@ func (db *DBIndexer) Index(id int64) error {
 
 	gitRepo, err := git.OpenRepositoryCtx(ctx, repo.RepoPath())
 	if err != nil {
+		if err.Error() == "no such file or directory" {
+			return nil
+		}
 		return err
 	}
 	defer gitRepo.Close()