fix: store downloaded config on file name hash

This commit is contained in:
Jan De Dobbeleer 2023-08-26 21:25:13 +02:00 committed by Jan De Dobbeleer
parent fc50dd4da8
commit b5bde55cf2

View file

@ -3,6 +3,7 @@ package platform
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@ -345,7 +346,9 @@ func (env *Shell) resolveConfigPath() {
func (env *Shell) downloadConfig(location string) error {
defer env.Trace(time.Now(), location)
ext := filepath.Ext(location)
configPath := filepath.Join(env.CachePath(), "config.omp"+ext)
fileHash := base64.StdEncoding.EncodeToString([]byte(location))
filename := fmt.Sprintf("config.%s.omp%s", fileHash, ext)
configPath := filepath.Join(env.CachePath(), filename)
cfg, err := env.HTTPRequest(location, nil, 5000)
if err != nil {
return err