From d21c05bd85b9a6a044625d90e64902e349bc7869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 10 Dec 2019 13:15:10 +0100 Subject: [PATCH] paramfetch: respect FIL_PROOFS_PARAMETER_CACHE --- build/paramfetch.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build/paramfetch.go b/build/paramfetch.go index b647f675b..14bb80f29 100644 --- a/build/paramfetch.go +++ b/build/paramfetch.go @@ -25,6 +25,7 @@ var log = logging.Logger("build") //const gateway = "http://198.211.99.118/ipfs/" const gateway = "https://ipfs.io/ipfs/" const paramdir = "/var/tmp/filecoin-proof-parameters" +const dirEnv = "FIL_PROOFS_PARAMETER_CACHE" type paramFile struct { Cid string `json:"cid"` @@ -39,8 +40,15 @@ type fetch struct { errs []error } +func getParamDir() string { + if os.Getenv(dirEnv) == "" { + return paramdir + } + return os.Getenv(dirEnv) +} + func GetParams(storageSize uint64) error { - if err := os.Mkdir(paramdir, 0755); err != nil && !os.IsExist(err) { + if err := os.Mkdir(getParamDir(), 0755); err != nil && !os.IsExist(err) { return err } @@ -70,7 +78,7 @@ func (ft *fetch) maybeFetchAsync(name string, info paramFile) { go func() { defer ft.wg.Done() - path := filepath.Join(paramdir, name) + path := filepath.Join(getParamDir(), name) err := ft.checkFile(path, info) if !os.IsNotExist(err) && err != nil {