Warn if mkpuzzle is not executable

This commit is contained in:
Neale Pickett 2020-10-20 11:15:46 -06:00
parent d016555fb4
commit e6dfebdbfe
1 changed files with 14 additions and 9 deletions

View File

@ -11,6 +11,7 @@ import (
"io"
"log"
"net/mail"
"os"
"os/exec"
"path"
"strconv"
@ -140,17 +141,21 @@ type PuzzleProvider interface {
func NewFsPuzzle(fs afero.Fs) PuzzleProvider {
var command string
if info, err := fs.Stat("mkpuzzle"); (err == nil) && (info.Mode()&0100 != 0) {
if info, err := fs.Stat("mkpuzzle"); !os.IsNotExist(err) {
if (info.Mode() & 0100) != 0 {
// Try to get the actual path to the executable
if pfs, ok := fs.(*RecursiveBasePathFs); ok {
if command, err = pfs.RealPath(info.Name()); err != nil {
log.Println("Unable to resolve full path to", info.Name(), pfs)
log.Println("WARN: Unable to resolve full path to", info.Name(), pfs)
}
} else if pfs, ok := fs.(*afero.BasePathFs); ok {
if command, err = pfs.RealPath(info.Name()); err != nil {
log.Println("Unable to resolve full path to", info.Name(), pfs)
log.Println("WARN: Unable to resolve full path to", info.Name(), pfs)
}
}
} else {
log.Println("WARN: mkpuzzle exists, but isn't executable.")
}
}
if command != "" {