mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
refactor: download config on new version only
This commit is contained in:
parent
8b5c2a35ca
commit
035134a79a
|
@ -261,11 +261,30 @@ func (env *ShellEnvironment) resolveConfigPath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *ShellEnvironment) getConfigPath(location string) {
|
func (env *ShellEnvironment) getConfigPath(location string) {
|
||||||
|
configFileName := fmt.Sprintf("%s.omp.json", env.Version)
|
||||||
|
configPath := filepath.Join(env.CachePath(), configFileName)
|
||||||
|
if env.HasFilesInDir(env.CachePath(), configFileName) {
|
||||||
|
env.CmdFlags.Config = configPath
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// clean old config files
|
||||||
|
cleanCacheDir := func() {
|
||||||
|
dir, err := ioutil.ReadDir(env.CachePath())
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, file := range dir {
|
||||||
|
if strings.HasSuffix(file.Name(), ".omp.json") {
|
||||||
|
os.Remove(filepath.Join(env.CachePath(), file.Name()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cleanCacheDir()
|
||||||
|
|
||||||
cfg, err := env.HTTPRequest(location, 5000)
|
cfg, err := env.HTTPRequest(location, 5000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
configPath := filepath.Join(env.CachePath(), "config.omp.json")
|
|
||||||
out, err := os.Create(configPath)
|
out, err := os.Create(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue