Move locating mods to index

This commit is contained in:
comp500
2019-06-15 00:40:56 +01:00
parent 91693cd3eb
commit adcde05693
3 changed files with 47 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ import (
"path/filepath"
"sort"
"time"
"strings"
"github.com/BurntSushi/toml"
"github.com/vbauerster/mpb/v4"
@@ -266,3 +267,17 @@ func (in *Index) RefreshFileWithHash(path, format, hash string, mod bool) error
in.resortIndex()
return nil
}
// FindMod finds a mod in the index and returns it's path and whether it has been found
func (in Index) FindMod(modName string) (string, bool) {
for _, v := range in.Files {
if v.MetaFile {
_, file := filepath.Split(v.File);
fileTrimmed := strings.TrimSuffix(file, ModExtension)
if fileTrimmed == modName {
return v.File, true
}
}
}
return "", false
}