mirror of https://github.com/dirtbags/moth.git
Warn if mkpuzzle is not executable
This commit is contained in:
parent
d016555fb4
commit
e6dfebdbfe
|
@ -11,6 +11,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"net/mail"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strconv"
|
||||
|
@ -140,16 +141,20 @@ type PuzzleProvider interface {
|
|||
func NewFsPuzzle(fs afero.Fs) PuzzleProvider {
|
||||
var command string
|
||||
|
||||
if info, err := fs.Stat("mkpuzzle"); (err == nil) && (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)
|
||||
}
|
||||
} 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)
|
||||
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("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("WARN: Unable to resolve full path to", info.Name(), pfs)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Println("WARN: mkpuzzle exists, but isn't executable.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue