1
0
Fork 0
forked from forgejo/forgejo

Restrict repository indexing by file extension

This commit is contained in:
Guillermo Prandi 2019-08-06 01:01:28 -03:00
parent 026696b87a
commit a85393b655
3 changed files with 35 additions and 0 deletions

View file

@ -232,6 +232,17 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e
}
func isIndexable(entry *git.TreeEntry) bool {
if setting.Indexer.FileExtensions != nil {
var ext string
parts := strings.Split(entry.Name(), ".")
cnt := len(parts)
if cnt > 1 {
ext = strings.ToLower(parts[cnt-1])
}
if setting.Indexer.FileExtensions[ext] == setting.Indexer.ExcludeExtensions {
return false
}
}
return entry.IsRegular() || entry.IsExecutable()
}