abef90423d
`os.ReadDir` was added in Go 1.16 as part of the deprecation of `ioutil` package. It is a more efficient implementation than `ioutil.ReadDir`. Reference: https://pkg.go.dev/io/ioutil#ReadDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
35 lines
901 B
Go
35 lines
901 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func sanityCheck() {
|
|
enhanceMsg := func(msg string, a ...interface{}) string {
|
|
return fmt.Sprintf("sanity check: "+msg+"; if running on local:exec, make sure to run `make` from the root of the oni repo", a...)
|
|
}
|
|
|
|
dir := "/var/tmp/filecoin-proof-parameters"
|
|
stat, err := os.Stat(dir)
|
|
if os.IsNotExist(err) {
|
|
panic(enhanceMsg("proofs parameters not available in /var/tmp/filecoin-proof-parameters"))
|
|
}
|
|
if err != nil {
|
|
panic(enhanceMsg("failed to stat /var/tmp/filecoin-proof-parameters: %s", err))
|
|
}
|
|
|
|
if !stat.IsDir() {
|
|
panic(enhanceMsg("/var/tmp/filecoin-proof-parameters is not a directory; aborting"))
|
|
}
|
|
|
|
files, err := os.ReadDir(dir)
|
|
if err != nil {
|
|
panic(enhanceMsg("failed list directory /var/tmp/filecoin-proof-parameters: %s", err))
|
|
}
|
|
|
|
if len(files) == 0 {
|
|
panic(enhanceMsg("no files in /var/tmp/filecoin-proof-parameters"))
|
|
}
|
|
}
|